# load styler for styling the R code. Create citations for the thesis report.
# Remaining packages are loaded while coding.
library(styler)
library(report)
citation("report")
citation("styler")

Thesis code file

This document can serve as a guideline for performing a social science or marketing study involving video analysis. The features retrieved from the video’s can be used to train and predict classification models.

This document holds the following structure:

Part 1: Preparing the data - Load the processed video CSV file into R - Combining different CSV files into a master data frame - Pre-process the data frame obtained by the loaded and combined data - Data cleaning steps - Feature creation - Creating descriptive statistics

Part 2: EDA - Descriptive statistics tables - Distribution analysis

Part 3: Train and predict - Train and test set - Training models (decision trees and SVM) - Prediction - Evaluation

Part 4: Remain code used in this project

A complete reference list of can be found in the thesis file. References of the packages used to create the code, can be found in the code blocks. They are not printed in the HTML or pdf output. Some ideas have been obtained using help forums like stackoverflow (https://stackoverflow.com/). Usually in the posts you can also find help debugging your code.

Disclaimer

The thesis and this RMarkdown code file do not contain any studies with human participants or animals performed by the author. Data used in this study were previously collected. The original owner of the data retains ownership of the data during and after the completion of this thesis.

Part 1: processing video’s into one dataset in R.

Before loading the data a new Project directory is created. All data used for this project is stored in this directory.

Load the data

The database is processed through OpenFace2.0 and consists of \(475\) csv files. These are loaded into R using the dplyr package. The original filename is added to the database using the flnm function. The function appends the filename to each record during the initial reading of the csv files. Next, this function reading multiple csv files add once is used, instead of the read_csv() function.

Attributions and Appreciations: With special thanks to: https://stackoverflow.com/users/5088194/leerssej for providing the code for both functions to append the filenames and load multiple csv files add once in one dataframe.

# load packages
library(tidyverse)
library(data.table)

# *dplyr()*
# `read_csv()`

# functions to load the data
read_plus <- function(flnm) {
  read_csv(flnm) %>%
    mutate(filename = flnm)
}

map_df_read_csv <- function(path, pattern = "*.csv") {
  list.files(path, pattern, full.names = TRUE) %>%
    map_df(~ read_plus(.))
}

# create a data frame and relocate the ID column as the first column
df <- map_df_read_csv("Data_Openface/CSV", "*.csv")
df %>% relocate(filename, .before = face_id)

# save the data frame
write.csv(x = df, file = "masterfile", row.names = FALSE)

# citation("tidyverse")
# citation("data.table")

Last step, the dataframe is saved as “masterfile” in the project directory.

Combining information about the dataset in one dataframe

Check the filename column using tables of a copy of the original dataframe. First, the dataframe is loaded the dataframe the project drive, and a copy of the file is created. Next, file names are changed into readable files to connect to the gender and age information from separate text files. Open the file of details. Adjust the filename column to be the same as the dataframe. Use inner_join() from the dplyr package to connect the two dataframes. Check the number of observations and variables. Last save the new dataframe as a csv raw database to work with in the next steps of the process, EDA and datacleaning.

From now on the masterfile_connected will be the raw database saved as it contains the full set of elements. The database contains of \(95,830\) observations and \(719\) variables.

# reload the data and create a copy as working file
library(tidyverse)
df <- read.csv("masterfile")
df_copy <- df
df_copy %>% relocate(filename, .before = face_id)
# check the data frame ID
table(df_copy$filename)

# clean filename information to a readable format
df_copy$filename <- gsub(".csv", "", df_copy$filename)
df_copy$filename <- gsub("Data_Openface/CSV/", "", df_copy$filename)
df_copy$filename
table(df_copy$filename)

# open file information from the text file
UvA_subjects <- read.csv("UvA-NEMO_Smile_Database_File_Details.txt",
  header = FALSE, skip = 4, sep = "\t"
)

# create column names
colnames(UvA_subjects) <-
  c("filename", "subject", "gender", "age", "smile_type")

# clean filename format
UvA_subjects$filename <- gsub(".mp4", "", UvA_subjects$filename)

# join the two datasets by filename
UvA_df <- inner_join(UvA_subjects, df_copy, "filename")

# save the data frame
write.csv(x = UvA_df, file = "masterfile_connected", row.names = FALSE)

Data cleaning

For datacleaning, the masterfile_connected is used and will serve as base for further pre-processing. Next step is checking the data for NA’s. The colSums table shows there are no NA values in the database. A visualized NA report is showing no values meaning no NA’s and a full combination field for the dataframe.

# load packages
library(tidyverse)
library(dplyr)
library("VIM")

# load masterfile and create a copy
UvA_original <- read.csv("masterfile_connected")

# check for NA's on different levels using tables and summary data
table(UvA_original$subject, useNA = "always")
table(UvA_original$subject, UvA_original$age)
colSums(is.na(UvA_original))
aggr(UvA_original)

table(UvA_original$age, UvA_original$smile_type)
table(UvA_original$gender, UvA_original$smile_type)
table(UvA_original$smile_type, UvA_original$subject)
summary(UvA_original[, 1:10])
summary(UvA_original[, 11:20])

# AU selection check
summary(UvA_original[, 700:719])

citation("dplyr")
citation("VIM")

Next the confidence and success rate from the original file are checked. All \(95.830\) video frames are processed successfully by OpenFace and the mean() confidence rate is \(98%\).

# Check the confidence and success rate of the loaded video's.
table(UvA_original$confidence)
## 
##  0.88  0.93  0.98 
##     6  2150 93674
table(UvA_original$success)
## 
##     1 
## 95830
mean(UvA_original$confidence)
## [1] 0.978872

Feature selection and creation.

After loading and checking the data the next step is to create and select the features for the models. There are three different types of features to work with in this research question: parts or symmetry of the face, facial expression and temporal features. In the code below, the dataset is converted to a final dataset including all the features either selected or created. This final dataset is used in the next part of the report to build the models and perform the analysis.In the thesis report an elaboration will be given on the description, selection and calculation of the features.

# load packages
library(readr)
library(scales)

# create a copy from the original dataset to create the final dataset
UvA_final <- UvA_original

# select and create the features for the database using a pipeline
UvA_final <- UvA_final %>%
  select(
    filename, subject, gender, age, smile_type, frame, timestamp,
    starts_with("gaze_angle"), starts_with("pose_"), starts_with("AU"),
    x_36, x_37, x_38, x_39, x_42, x_43, x_44, x_45, x_48, x_54, y_36, y_37,
    y_38, y_39, y_42, y_43, y_44, y_45, y_48, y_54
  ) %>%
  mutate(AU06_12_c = ifelse(AU06_c == 1 & AU12_c == 1, 1, 0)) %>%
  mutate(lip = sqrt((x_48 - x_54)^2 + (y_48 - y_54)^2)) %>%
  mutate(eye_x_m_l = (x_36 + x_39) / 2) %>%
  mutate(eye_y_m_l = (y_36 + y_39) / 2) %>%
  mutate(eye_x_m_r = (x_42 + x_45) / 2) %>%
  mutate(eye_y_m_r = (y_42 + y_45) / 2) %>%
  mutate(eye_x_u_l = (x_37 + x_38) / 2) %>%
  mutate(eye_y_u_l = (y_37 + y_38) / 2) %>%
  mutate(eye_x_u_r = (x_43 + x_44) / 2) %>%
  mutate(eye_y_u_r = (y_43 + y_44) / 2) %>%
  mutate(
    eye_l = sqrt((eye_x_m_l - eye_x_u_l)^2 + (eye_y_m_l - eye_y_u_l)^2)
  ) %>%
  mutate(
    eye_r = sqrt((eye_x_m_r - eye_x_u_r)^2 + (eye_y_m_r - eye_y_u_r)^2)
  ) %>%
  mutate(eye = (eye_l + eye_r) / 2) %>%
  mutate(lip_m_x = (x_48 + x_54) / 2) %>%
  mutate(lip_m_y = (y_48 + y_54) / 2) %>%
  mutate(amplitude = rescale(sqrt((x_54 - lip_m_x)^2 + (y_54 - lip_m_y)^2))) %>%
  mutate(duration = 0.02) %>%
  mutate(stage = duration / amplitude) %>%
  group_by(filename) %>%
  mutate(apex = ifelse(amplitude > mean(amplitude), amplitude, NA)) %>%
  mutate(onset_offset = ifelse(amplitude <= mean(amplitude), amplitude, NA)) %>%
  mutate(onset = ifelse(onset_offset & frame < mean(frame), amplitude, NA)) %>%
  mutate(offset = ifelse(onset_offset & frame >= mean(frame),
    amplitude, NA
  )) %>%
  select(
    filename, subject, gender, age, smile_type, frame, timestamp,
    starts_with("gaze"), starts_with("pose_R"),
    starts_with("AU") & ends_with("_r"),
    lip, eye, amplitude, stage, apex, offset, onset
  ) %>%
  ungroup()

# save the final file.
write_csv(UvA_final, "UvA_final")

# Mathematical Notes:

# distance between landmark points 36 and 39 left and 42 and 45 right eyes
# eye middle point of x and y = x_eye_middle (x36 + x39)/2 etc y
# eye upper middle point of x and y = x_eye_upper_middle (x37 + x38)/2
# same for the right eye

# euclidean distance for eye: srqt(x2-x1)^2+(y2-y1)^2
# see calculation lip but than for eye_middle point vs eye_upper_point

# eye gaze only take the angle

# duration ratio = timestamp/duration
# amplitude = lip middle towards left lip corner

# check if sum stats are the same as with OpenFacer - done same result
# all(UvA_face_check$pose_Tz_sd, UvA_sum$pose_Tz_sd)

# citation("readr")
# citation("scales")

Temporal features apex, onset & offset

For apex, onset and offset, four options for defining the stages have been reviewed. All options show about the same signal as the lip amplitude feature created to measure onset, apex and offset. The options are, the longest subsequence and, start, middle and end point of AU06 and starting point of AU12, based on the categorical variables, and the mean abline() of amplitude. AU12 proves to be always there and starts at different levels for every subject, so this feature could not be used as the categorical variable always displays one. The same goes for the amplitude itself, but because the data show a relative long apex face, the mean is close to the apex value. Therefore a split of stages based on the mean abline() would be a solid solution. The longest subsequence variable could be used as it concerns a single smile but does not show a stable enough sequence to be used (see picture). The AU06 categorical variable starts from zero with every subject, but about 80 participants do not show a offset based on this metric. Therefore the choice is to proceed with the mean abline() split point of the three stages, onset, apex and offset.The plot shows all 4 as an illustration.

Attributions and Appreciations: With special thanks to: Jinjing Xie https://www.r-bloggers.com/2014/09/compute-longest-increasingdecreasing-subsequence-using-rcpp/ for providing the code for the function.

# load packages
library(compiler)

# function for creating longest sub sequence
longest_subseq.R <- cmpfun(function(x) {
  P <- integer(length(x))
  M <- integer(length(x) + 1)
  L <- newL <- 0
  for (i in seq_along(x) - 1) {
    lo <- 1
    hi <- L
    while (lo <= hi) {
      mid <- (lo + hi) %/% 2
      if (x[M[mid + 1] + 1] < x[i + 1]) {
        lo <- mid + 1
      } else {
        hi <- mid - 1
      }
    }
    newL <- lo
    P[i + 1] <- M[newL]
    if (newL > L) {
      M[newL + 1] <- i
      L <- newL
    } else if (x[i + 1] < x[M[newL + 1] + 1]) {
      M[newL + 1] <- i
    }
  }
  k <- M[L + 1]
  re <- integer(L)
  for (i in L:1) {
    re[i] <- k + 1
    k <- P[k + 1]
  }
  re
})

# check the result of one participant number 20.
longest_subseq.R(UvA_final$amplitude[1:193])
##  [1]   2   3   5   6   8   9  11  12  13  14  15  16  17  18  19  20  21  22  23
## [20]  24  48  49  50  51  52  53  54  59  60  61  67  68  70  72  78  79  80  83
## [39]  85  90  94  95 100 101 106 108 110 111 113 115 116 119 121
# create graphs to check the four options.
par(mfrow = c(2, 2))
par(mai = c(.8, .8, .2, .2))

# option 1: mean calculation
plot(UvA_final$frame[1:193], UvA_final$amplitude[1:193],
  main = "Sequences amplitude",
  ylab = "amplitude", xlab = "frame", pch = 16, col = "#0000004D",
  cex.main = 0.7
)
abline(mean(UvA_final$amplitude[1:193]), 0, col = "blue", pch = 16)
abline(v = 15, lty = 2)
abline(v = 175, lty = 2)
text(5, 0.7, "onset")
text(100, 0.7, "apex")
text(187, 0.7, "offset")

# option 2: AU12
plot(UvA_final$frame[1:193], UvA_final$AU12_r[1:193],
  main = "Sequences AU12_r",
  ylab = "amplitude", xlab = "frame", pch = 16, col = "#0000004D",
  cex.main = 0.7
)

# option 3: AU06
plot(UvA_final$frame[1:193], UvA_final$AU06_r[1:193],
  main = "Sequences AU06_r",
  ylab = "amplitude", xlab = "frame", pch = 16, col = "#0000004D",
  cex.main = 0.7
)

# option 4: LIS (increasing and decreasing)
plot(UvA_final$amplitude[1:193],
  main = "Longest Increasing (blue) and Decreasing (red) Subsequences",
  ylab = "amplitude", xlab = "frame", pch = 16, col = "#0000004D",
  cex.main = 0.7
)
ind <- longest_subseq.R(UvA_final$amplitude[1:193])
ind
##  [1]   2   3   5   6   8   9  11  12  13  14  15  16  17  18  19  20  21  22  23
## [20]  24  48  49  50  51  52  53  54  59  60  61  67  68  70  72  78  79  80  83
## [39]  85  90  94  95 100 101 106 108 110 111 113 115 116 119 121
points(ind, UvA_final$amplitude[1:193][ind], pch = 16, col = "blue")
rind <- longest_subseq.R(-UvA_final$amplitude[1:193])
rind
##  [1] 118 121 122 123 125 144 145 146 147 154 155 156 159 164 166 167 169 170 171
## [20] 172 173 174 175 176 177 178 188 190 192 193
points(rind, UvA_final$amplitude[1:193][rind], pch = 16, col = "red")

# citation("compiler")

Creating descriptive satistics

With the final dataset, summary statistics are created using 2 files. The first file will contain the summary statistics, minimum value min(), maximum value max(), the average value mean() and standard deviation sd(). The min() and max() values will be analyzed from the tables and for the mean() and sd() histograms are made to show the distribution as well as the difference in distribution between the two smile types. This section will be used a set to report these values in the thesis if applicable, e.g., the average time of the video recording or the number of frames. The second file of summary statistics will be used as the input file for models and will contain the mean values only, as described in part 2.

# load packages
library(scales)
library(tidyverse)
library(dplyr)

# create a file to create the summary static files from the the final dataset.
# Using a copy of the final dataset.
UvA_basis <- read.csv("UvA_final")
dim(UvA_basis)
## [1] 95830    36
# file 1 containing all summary statistics for all features.
UvA_sum <- UvA_basis %>%
  group_by(filename, subject, gender, age, smile_type) %>%
  summarise_all(list(min = min, max = max, mean = mean, sd = sd), na.rm = TRUE)
# save the file
write_csv(UvA_sum, "UvA_sum")


# file 2 create set of features with value mean.
UvA_modelset <- UvA_basis %>%
  select(
    filename, subject, gender, age, smile_type, gaze_angle_x, gaze_angle_y,
    pose_Rx, pose_Ry, pose_Rz, starts_with("AU") & ends_with("_r"),
    lip, eye, amplitude, stage, apex, offset, onset
  ) %>%
  group_by(filename, subject, gender, age, smile_type) %>%
  summarise_all(list(mean = mean), na.rm = TRUE) %>%
  ungroup()
# save the file
write_csv(UvA_modelset, "UvA_modelset")

EDA

Decriptive statistics tables

An overall table of the descriptive statistics is created by the summery() function. For a split based on the classification the psych package is used with the describeBy() function which groups the classifier smile_type and smile_type + gender. Both these files will be analyzed used the output table.

# load packages
library(psych)

# the overall summary of the descriptive statistics
desc_stats <- summary(UvA_sum)
desc_stats
##    filename            subject         gender               age       
##  Length:475         Min.   : 20.0   Length:475         Min.   : 8.00  
##  Class :character   1st Qu.:161.5   Class :character   1st Qu.: 9.00  
##  Mode  :character   Median :272.0   Mode  :character   Median :10.00  
##                     Mean   :286.7                      Mean   :10.86  
##                     3rd Qu.:449.0                      3rd Qu.:12.00  
##                     Max.   :543.0                      Max.   :17.00  
##                                                                       
##   smile_type          frame_min timestamp_min gaze_angle_x_min 
##  Length:475         Min.   :1   Min.   :0     Min.   :-0.1720  
##  Class :character   1st Qu.:1   1st Qu.:0     1st Qu.: 0.1040  
##  Mode  :character   Median :1   Median :0     Median : 0.1580  
##                     Mean   :1   Mean   :0     Mean   : 0.1478  
##                     3rd Qu.:1   3rd Qu.:0     3rd Qu.: 0.2000  
##                     Max.   :1   Max.   :0     Max.   : 0.3920  
##                                                                
##  gaze_angle_y_min   pose_Rx_min       pose_Ry_min       pose_Rz_min      
##  Min.   :-0.1260   Min.   :-0.3730   Min.   :-0.4630   Min.   :-0.37500  
##  1st Qu.: 0.1485   1st Qu.: 0.0370   1st Qu.:-0.2490   1st Qu.:-0.08500  
##  Median : 0.2080   Median : 0.1150   Median :-0.2020   Median :-0.03700  
##  Mean   : 0.2041   Mean   : 0.1031   Mean   :-0.1978   Mean   :-0.04409  
##  3rd Qu.: 0.2590   3rd Qu.: 0.1760   3rd Qu.:-0.1435   3rd Qu.: 0.00700  
##  Max.   : 0.4840   Max.   : 0.3110   Max.   : 0.0360   Max.   : 0.12900  
##                                                                          
##    AU01_r_min   AU02_r_min   AU04_r_min       AU05_r_min   AU06_r_min     
##  Min.   :0    Min.   :0    Min.   :0.0000   Min.   :0    Min.   :0.00000  
##  1st Qu.:0    1st Qu.:0    1st Qu.:0.0000   1st Qu.:0    1st Qu.:0.00000  
##  Median :0    Median :0    Median :0.0000   Median :0    Median :0.00000  
##  Mean   :0    Mean   :0    Mean   :0.1395   Mean   :0    Mean   :0.06373  
##  3rd Qu.:0    3rd Qu.:0    3rd Qu.:0.0000   3rd Qu.:0    3rd Qu.:0.00000  
##  Max.   :0    Max.   :0    Max.   :3.3600   Max.   :0    Max.   :1.82000  
##                                                                           
##    AU07_r_min       AU09_r_min   AU10_r_min        AU12_r_min    
##  Min.   :0.0000   Min.   :0    Min.   :0.00000   Min.   :0.0000  
##  1st Qu.:0.0000   1st Qu.:0    1st Qu.:0.00000   1st Qu.:0.0000  
##  Median :0.0000   Median :0    Median :0.00000   Median :0.0000  
##  Mean   :0.2175   Mean   :0    Mean   :0.02585   Mean   :0.2299  
##  3rd Qu.:0.1500   3rd Qu.:0    3rd Qu.:0.00000   3rd Qu.:0.3500  
##  Max.   :3.5900   Max.   :0    Max.   :1.64000   Max.   :2.5600  
##                                                                  
##    AU14_r_min      AU15_r_min   AU17_r_min   AU20_r_min   AU23_r_min
##  Min.   :0.000   Min.   :0    Min.   :0    Min.   :0    Min.   :0   
##  1st Qu.:0.110   1st Qu.:0    1st Qu.:0    1st Qu.:0    1st Qu.:0   
##  Median :0.510   Median :0    Median :0    Median :0    Median :0   
##  Mean   :0.534   Mean   :0    Mean   :0    Mean   :0    Mean   :0   
##  3rd Qu.:0.840   3rd Qu.:0    3rd Qu.:0    3rd Qu.:0    3rd Qu.:0   
##  Max.   :1.850   Max.   :0    Max.   :0    Max.   :0    Max.   :0   
##                                                                     
##    AU25_r_min   AU26_r_min   AU45_r_min    lip_min          eye_min       
##  Min.   :0    Min.   :0    Min.   :0    Min.   : 95.03   Min.   : 0.3457  
##  1st Qu.:0    1st Qu.:0    1st Qu.:0    1st Qu.:136.17   1st Qu.: 2.7174  
##  Median :0    Median :0    Median :0    Median :148.75   Median : 4.8403  
##  Mean   :0    Mean   :0    Mean   :0    Mean   :148.52   Mean   : 5.7299  
##  3rd Qu.:0    3rd Qu.:0    3rd Qu.:0    3rd Qu.:159.62   3rd Qu.: 8.7795  
##  Max.   :0    Max.   :0    Max.   :0    Max.   :204.53   Max.   :15.4864  
##                                                                           
##  amplitude_min      stage_min          apex_min        offset_min       
##  Min.   :0.0000   Min.   :0.02000   Min.   :0.1344   Min.   :0.0006176  
##  1st Qu.:0.2745   1st Qu.:0.02731   1st Qu.:0.4488   1st Qu.:0.2973016  
##  Median :0.3585   Median :0.03148   Median :0.5412   Median :0.3917766  
##  Mean   :0.3569   Mean   :0.03383   Mean   :0.5388   Mean   :0.3886023  
##  3rd Qu.:0.4310   3rd Qu.:0.03715   3rd Qu.:0.6427   3rd Qu.:0.4754893  
##  Max.   :0.7306   Max.   :0.09461   Max.   :0.9014   Max.   :0.7306418  
##                                                                         
##    onset_min         frame_max     timestamp_max    gaze_angle_x_max
##  Min.   :0.02589   Min.   : 55.0   Min.   : 1.080   Min.   :0.0170  
##  1st Qu.:0.29948   1st Qu.:136.5   1st Qu.: 2.710   1st Qu.:0.1990  
##  Median :0.38134   Median :176.0   Median : 3.500   Median :0.2480  
##  Mean   :0.37796   Mean   :201.7   Mean   : 4.015   Mean   :0.2441  
##  3rd Qu.:0.45648   3rd Qu.:234.0   3rd Qu.: 4.660   3rd Qu.:0.2935  
##  Max.   :0.75256   Max.   :705.0   Max.   :14.080   Max.   :0.4680  
##                                                                     
##  gaze_angle_y_max  pose_Rx_max       pose_Ry_max       pose_Rz_max      
##  Min.   :0.0710   Min.   :-0.0980   Min.   :-0.4020   Min.   :-0.15900  
##  1st Qu.:0.3325   1st Qu.: 0.1615   1st Qu.:-0.1875   1st Qu.:-0.00750  
##  Median :0.4040   Median : 0.2180   Median :-0.1320   Median : 0.03700  
##  Mean   :0.4077   Mean   : 0.2116   Mean   :-0.1313   Mean   : 0.04434  
##  3rd Qu.:0.4855   3rd Qu.: 0.2805   3rd Qu.:-0.0775   3rd Qu.: 0.08600  
##  Max.   :0.6920   Max.   : 0.4460   Max.   : 0.1810   Max.   : 0.33100  
##                                                                         
##    AU01_r_max       AU02_r_max       AU04_r_max       AU05_r_max    
##  Min.   :0.1300   Min.   :0.1300   Min.   :0.0000   Min.   :0.1000  
##  1st Qu.:0.4150   1st Qu.:0.3500   1st Qu.:0.0000   1st Qu.:0.3000  
##  Median :0.6500   Median :0.4700   Median :0.2000   Median :0.4600  
##  Mean   :0.7772   Mean   :0.5596   Mean   :0.5686   Mean   :0.5215  
##  3rd Qu.:0.9150   3rd Qu.:0.6300   3rd Qu.:0.8300   3rd Qu.:0.6500  
##  Max.   :5.0000   Max.   :3.0900   Max.   :4.4900   Max.   :2.3400  
##                                                                     
##    AU06_r_max      AU07_r_max      AU09_r_max       AU10_r_max   
##  Min.   :0.000   Min.   :0.000   Min.   :0.0800   Min.   :0.000  
##  1st Qu.:1.265   1st Qu.:1.165   1st Qu.:0.2100   1st Qu.:0.615  
##  Median :1.740   Median :1.770   Median :0.2900   Median :1.270  
##  Mean   :1.800   Mean   :1.804   Mean   :0.3511   Mean   :1.210  
##  3rd Qu.:2.320   3rd Qu.:2.400   3rd Qu.:0.4400   3rd Qu.:1.740  
##  Max.   :3.740   Max.   :5.000   Max.   :1.8800   Max.   :3.340  
##                                                                  
##    AU12_r_max      AU14_r_max      AU15_r_max       AU17_r_max   
##  Min.   :0.790   Min.   :0.030   Min.   :0.1300   Min.   :0.290  
##  1st Qu.:2.390   1st Qu.:1.540   1st Qu.:0.2750   1st Qu.:0.835  
##  Median :2.800   Median :1.850   Median :0.3900   Median :1.200  
##  Mean   :2.782   Mean   :1.851   Mean   :0.4486   Mean   :1.274  
##  3rd Qu.:3.200   3rd Qu.:2.170   3rd Qu.:0.5450   3rd Qu.:1.560  
##  Max.   :4.700   Max.   :3.430   Max.   :2.7600   Max.   :3.970  
##                                                                  
##    AU20_r_max       AU23_r_max       AU25_r_max      AU26_r_max   
##  Min.   :0.1000   Min.   :0.0900   Min.   :0.310   Min.   :0.290  
##  1st Qu.:0.3000   1st Qu.:0.3100   1st Qu.:0.745   1st Qu.:0.780  
##  Median :0.4200   Median :0.5200   Median :1.140   Median :1.030  
##  Mean   :0.4768   Mean   :0.5904   Mean   :1.340   Mean   :1.143  
##  3rd Qu.:0.5900   3rd Qu.:0.7500   3rd Qu.:1.835   3rd Qu.:1.350  
##  Max.   :1.6100   Max.   :1.9100   Max.   :3.460   Max.   :4.730  
##                                                                   
##    AU45_r_max       lip_max         eye_max       amplitude_max   
##  Min.   :0.220   Min.   :126.7   Min.   : 7.248   Min.   :0.2114  
##  1st Qu.:0.610   1st Qu.:175.7   1st Qu.:11.375   1st Qu.:0.5384  
##  Median :1.730   Median :190.3   Median :12.624   Median :0.6354  
##  Mean   :1.803   Mean   :189.2   Mean   :12.747   Mean   :0.6282  
##  3rd Qu.:2.855   3rd Qu.:204.8   3rd Qu.:14.077   3rd Qu.:0.7323  
##  Max.   :5.000   Max.   :244.9   Max.   :22.049   Max.   :1.0000  
##                                                                   
##    stage_max          apex_max        offset_max       onset_max     
##  Min.   :0.02737   Min.   :0.2114   Min.   :0.1277   Min.   :0.1330  
##  1st Qu.:0.04640   1st Qu.:0.5384   1st Qu.:0.4402   1st Qu.:0.4401  
##  Median :0.05579   Median :0.6354   Median :0.5288   Median :0.5301  
##  Mean   :    Inf   Mean   :0.6282   Mean   :0.5284   Mean   :0.5295  
##  3rd Qu.:0.07286   3rd Qu.:0.7323   3rd Qu.:0.6303   3rd Qu.:0.6311  
##  Max.   :    Inf   Max.   :1.0000   Max.   :0.8980   Max.   :0.8867  
##                                                                      
##    frame_mean     timestamp_mean  gaze_angle_x_mean  gaze_angle_y_mean  
##  Min.   : 28.00   Min.   :0.540   Min.   :-0.03577   Min.   :-0.004175  
##  1st Qu.: 68.75   1st Qu.:1.355   1st Qu.: 0.15391   1st Qu.: 0.235610  
##  Median : 88.50   Median :1.750   Median : 0.20332   Median : 0.287323  
##  Mean   :101.37   Mean   :2.007   Mean   : 0.19704   Mean   : 0.282436  
##  3rd Qu.:117.50   3rd Qu.:2.330   3rd Qu.: 0.24110   3rd Qu.: 0.329117  
##  Max.   :353.00   Max.   :7.040   Max.   : 0.42931   Max.   : 0.520731  
##                                                                         
##   pose_Rx_mean      pose_Ry_mean      pose_Rz_mean         AU01_r_mean     
##  Min.   :-0.1145   Min.   :-0.4267   Min.   :-0.1801186   Min.   :0.03137  
##  1st Qu.: 0.1090   1st Qu.:-0.2119   1st Qu.:-0.0458966   1st Qu.:0.06947  
##  Median : 0.1732   Median :-0.1687   Median :-0.0003729   Median :0.10456  
##  Mean   : 0.1647   Mean   :-0.1646   Mean   : 0.0001707   Mean   :0.13077  
##  3rd Qu.: 0.2315   3rd Qu.:-0.1111   3rd Qu.: 0.0429667   3rd Qu.:0.15482  
##  Max.   : 0.3679   Max.   : 0.0518   Max.   : 0.2370769   Max.   :1.06200  
##                                                                            
##   AU02_r_mean       AU04_r_mean       AU05_r_mean       AU06_r_mean    
##  Min.   :0.01783   Min.   :0.00000   Min.   :0.01407   Min.   :0.0000  
##  1st Qu.:0.03469   1st Qu.:0.00000   1st Qu.:0.02607   1st Qu.:0.6064  
##  Median :0.04575   Median :0.01016   Median :0.03526   Median :0.9590  
##  Mean   :0.05639   Mean   :0.29150   Mean   :0.04307   Mean   :1.0220  
##  3rd Qu.:0.06178   3rd Qu.:0.26155   3rd Qu.:0.05253   3rd Qu.:1.4284  
##  Max.   :0.37496   Max.   :3.75359   Max.   :0.24129   Max.   :2.9500  
##                                                                        
##   AU07_r_mean      AU09_r_mean       AU10_r_mean      AU12_r_mean    
##  Min.   :0.0000   Min.   :0.01123   Min.   :0.0000   Min.   :0.3104  
##  1st Qu.:0.3844   1st Qu.:0.02544   1st Qu.:0.1689   1st Qu.:1.5263  
##  Median :0.8927   Median :0.03456   Median :0.5586   Median :1.8963  
##  Mean   :1.0017   Mean   :0.04377   Mean   :0.6229   Mean   :1.8779  
##  3rd Qu.:1.4146   3rd Qu.:0.05073   3rd Qu.:0.9638   3rd Qu.:2.2728  
##  Max.   :4.8921   Max.   :0.29978   Max.   :2.1251   Max.   :3.3969  
##                                                                      
##   AU14_r_mean        AU15_r_mean       AU17_r_mean       AU20_r_mean     
##  Min.   :0.001011   Min.   :0.02597   Min.   :0.07526   Min.   :0.01914  
##  1st Qu.:1.058506   1st Qu.:0.05114   1st Qu.:0.22504   1st Qu.:0.04126  
##  Median :1.318199   Median :0.06472   Median :0.32262   Median :0.05595  
##  Mean   :1.312488   Mean   :0.07568   Mean   :0.36455   Mean   :0.06591  
##  3rd Qu.:1.613258   3rd Qu.:0.08640   3rd Qu.:0.45501   3rd Qu.:0.07602  
##  Max.   :2.805286   Max.   :0.36451   Max.   :1.67080   Max.   :0.31641  
##                                                                          
##   AU23_r_mean       AU25_r_mean       AU26_r_mean       AU45_r_mean     
##  Min.   :0.01494   Min.   :0.06867   Min.   :0.08846   Min.   :0.03696  
##  1st Qu.:0.04066   1st Qu.:0.21927   1st Qu.:0.19091   1st Qu.:0.08465  
##  Median :0.06374   Median :0.40466   Median :0.26665   Median :0.14633  
##  Mean   :0.07844   Mean   :0.53228   Mean   :0.29881   Mean   :0.18336  
##  3rd Qu.:0.09597   3rd Qu.:0.74531   3rd Qu.:0.36326   3rd Qu.:0.24501  
##  Max.   :0.31894   Max.   :1.89141   Max.   :1.41270   Max.   :0.95777  
##                                                                         
##     lip_mean        eye_mean      amplitude_mean     stage_mean     
##  Min.   :115.1   Min.   : 4.653   Min.   :0.1342   Min.   :0.02283  
##  1st Qu.:162.0   1st Qu.: 9.114   1st Qu.:0.4468   1st Qu.:0.03222  
##  Median :175.8   Median :10.381   Median :0.5390   Median :0.03844  
##  Mean   :175.3   Mean   :10.466   Mean   :0.5358   Mean   :    Inf  
##  3rd Qu.:190.5   3rd Qu.:11.680   3rd Qu.:0.6373   3rd Qu.:0.04669  
##  Max.   :229.6   Max.   :17.306   Max.   :0.8981   Max.   :    Inf  
##                                                                     
##    apex_mean       offset_mean        onset_mean         frame_sd     
##  Min.   :0.1839   Min.   :0.02657   Min.   :0.03989   Min.   : 16.02  
##  1st Qu.:0.5044   1st Qu.:0.35351   1st Qu.:0.34981   1st Qu.: 39.55  
##  Median :0.6008   Median :0.44376   Median :0.43873   Median : 50.95  
##  Mean   :0.5959   Mean   :0.44482   Mean   :0.43614   Mean   : 58.38  
##  3rd Qu.:0.6972   3rd Qu.:0.54219   3rd Qu.:0.52342   3rd Qu.: 67.69  
##  Max.   :0.9582   Max.   :0.77740   Max.   :0.78238   Max.   :203.66  
##                                                                       
##   timestamp_sd    gaze_angle_x_sd    gaze_angle_y_sd      pose_Rx_sd      
##  Min.   :0.3204   Min.   :0.004268   Min.   :0.006175   Min.   :0.005344  
##  1st Qu.:0.7910   1st Qu.:0.012138   1st Qu.:0.026885   1st Qu.:0.015464  
##  Median :1.0190   Median :0.016913   Median :0.037900   Median :0.023031  
##  Mean   :1.1677   Mean   :0.020123   Mean   :0.040922   Mean   :0.027226  
##  3rd Qu.:1.3539   3rd Qu.:0.023455   3rd Qu.:0.051110   3rd Qu.:0.032555  
##  Max.   :4.0732   Max.   :0.101646   Max.   :0.122763   Max.   :0.156937  
##                                                                           
##    pose_Ry_sd         pose_Rz_sd         AU01_r_sd         AU02_r_sd      
##  Min.   :0.003045   Min.   :0.002531   Min.   :0.03744   Min.   :0.03076  
##  1st Qu.:0.008281   1st Qu.:0.009640   1st Qu.:0.10330   1st Qu.:0.06795  
##  Median :0.012707   Median :0.016293   Median :0.16113   Median :0.09569  
##  Mean   :0.016447   Mean   :0.023986   Mean   :0.20228   Mean   :0.11850  
##  3rd Qu.:0.020009   3rd Qu.:0.028439   3rd Qu.:0.24067   3rd Qu.:0.12989  
##  Max.   :0.094527   Max.   :0.165375   Max.   :1.77870   Max.   :0.79933  
##                                                                           
##    AU04_r_sd         AU05_r_sd         AU06_r_sd        AU07_r_sd     
##  Min.   :0.00000   Min.   :0.02550   Min.   :0.0000   Min.   :0.0000  
##  1st Qu.:0.00000   1st Qu.:0.05897   1st Qu.:0.4205   1st Qu.:0.2867  
##  Median :0.03379   Median :0.08229   Median :0.5532   Median :0.4026  
##  Mean   :0.10454   Mean   :0.10411   Mean   :0.5699   Mean   :0.4193  
##  3rd Qu.:0.17489   3rd Qu.:0.12720   3rd Qu.:0.7176   3rd Qu.:0.5393  
##  Max.   :0.67294   Max.   :0.60876   Max.   :1.3138   Max.   :1.2569  
##                                                                       
##    AU09_r_sd         AU10_r_sd        AU12_r_sd        AU14_r_sd      
##  Min.   :0.01757   Min.   :0.0000   Min.   :0.2404   Min.   :0.00543  
##  1st Qu.:0.04715   1st Qu.:0.1979   1st Qu.:0.6376   1st Qu.:0.22035  
##  Median :0.06596   Median :0.3946   Median :0.7956   Median :0.29707  
##  Mean   :0.08367   Mean   :0.3789   Mean   :0.8276   Mean   :0.31989  
##  3rd Qu.:0.10112   3rd Qu.:0.5431   3rd Qu.:0.9779   3rd Qu.:0.40174  
##  Max.   :0.56374   Max.   :1.1471   Max.   :2.0527   Max.   :0.82670  
##                                                                       
##    AU15_r_sd         AU17_r_sd         AU20_r_sd         AU23_r_sd      
##  Min.   :0.03162   Min.   :0.06655   Min.   :0.02474   Min.   :0.02427  
##  1st Qu.:0.07073   1st Qu.:0.21955   1st Qu.:0.06895   1st Qu.:0.07299  
##  Median :0.09319   Median :0.33761   Median :0.09610   Median :0.12103  
##  Mean   :0.11180   Mean   :0.37142   Mean   :0.11509   Mean   :0.14534  
##  3rd Qu.:0.13323   3rd Qu.:0.45936   3rd Qu.:0.14000   3rd Qu.:0.19001  
##  Max.   :0.64167   Max.   :1.49028   Max.   :0.52165   Max.   :0.54104  
##                                                                         
##    AU25_r_sd         AU26_r_sd         AU45_r_sd           lip_sd      
##  Min.   :0.06876   Min.   :0.06916   Min.   :0.04699   Min.   : 2.839  
##  1st Qu.:0.20905   1st Qu.:0.21161   1st Qu.:0.14292   1st Qu.: 9.507  
##  Median :0.37274   Median :0.29238   Median :0.31528   Median :11.928  
##  Mean   :0.46673   Mean   :0.32550   Mean   :0.37306   Mean   :12.429  
##  3rd Qu.:0.67814   3rd Qu.:0.39434   3rd Qu.:0.55286   3rd Qu.:15.330  
##  Max.   :1.43521   Max.   :1.46384   Max.   :1.50215   Max.   :31.297  
##                                                                        
##      eye_sd        amplitude_sd        stage_sd           apex_sd        
##  Min.   :0.1934   Min.   :0.01894   Min.   :0.001363   Min.   :0.005714  
##  1st Qu.:0.8221   1st Qu.:0.06344   1st Qu.:0.004642   1st Qu.:0.015893  
##  Median :1.3406   Median :0.07959   Median :0.006758   Median :0.021934  
##  Mean   :1.4573   Mean   :0.08293   Mean   :0.009031   Mean   :0.022950  
##  3rd Qu.:1.9303   3rd Qu.:0.10229   3rd Qu.:0.010379   3rd Qu.:0.028079  
##  Max.   :5.1009   Max.   :0.20884   Max.   :0.164760   Max.   :0.074245  
##                                     NA's   :1                            
##    offset_sd           onset_sd       
##  Min.   :0.001877   Min.   :0.002385  
##  1st Qu.:0.026013   1st Qu.:0.031080  
##  Median :0.038472   Median :0.045371  
##  Mean   :0.041893   Mean   :0.048238  
##  3rd Qu.:0.055286   3rd Qu.:0.062726  
##  Max.   :0.139375   Max.   :0.153071  
## 
# descriptive statistics per classifier
desc_stats_class <- describeBy(UvA_sum, UvA_sum$smile_type)
desc_stats_class
## 
##  Descriptive statistics by group 
## group: deliberate 
##                   vars   n   mean     sd median trimmed    mad    min    max
## filename*            1 240 120.50  69.43 120.50  120.50  88.96   1.00 240.00
## subject              2 240 290.22 154.82 277.00  289.55 214.98  20.00 543.00
## gender*              3 240   1.52   0.50   2.00    1.52   0.00   1.00   2.00
## age                  4 240  10.96   2.36  10.50   10.70   2.22   8.00  17.00
## smile_type*          5 240   1.00   0.00   1.00    1.00   0.00   1.00   1.00
## frame_min            6 240   1.00   0.00   1.00    1.00   0.00   1.00   1.00
## timestamp_min        7 240   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## gaze_angle_x_min     8 240   0.14   0.08   0.15    0.15   0.07  -0.17   0.37
## gaze_angle_y_min     9 240   0.21   0.09   0.22    0.21   0.08  -0.10   0.48
## pose_Rx_min         10 240   0.11   0.10   0.13    0.12   0.11  -0.33   0.29
## pose_Ry_min         11 240  -0.19   0.08  -0.20   -0.19   0.08  -0.44   0.03
## pose_Rz_min         12 240  -0.04   0.07  -0.03   -0.04   0.06  -0.26   0.09
## AU01_r_min          13 240   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU02_r_min          14 240   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU04_r_min          15 240   0.14   0.47   0.00    0.01   0.00   0.00   2.99
## AU05_r_min          16 240   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU06_r_min          17 240   0.05   0.19   0.00    0.00   0.00   0.00   1.35
## AU07_r_min          18 240   0.19   0.49   0.00    0.06   0.00   0.00   3.46
## AU09_r_min          19 240   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU10_r_min          20 240   0.02   0.13   0.00    0.00   0.00   0.00   1.64
## AU12_r_min          21 240   0.16   0.32   0.00    0.09   0.00   0.00   2.56
## AU14_r_min          22 240   0.51   0.44   0.47    0.47   0.53   0.00   1.82
## AU15_r_min          23 240   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU17_r_min          24 240   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU20_r_min          25 240   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU23_r_min          26 240   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU25_r_min          27 240   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU26_r_min          28 240   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU45_r_min          29 240   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## lip_min             30 240 147.95  18.35 147.61  147.84  17.94  95.03 204.53
## eye_min             31 240   5.79   3.64   5.06    5.53   4.20   0.54  15.49
## amplitude_min       32 240   0.35   0.12   0.35    0.35   0.12   0.00   0.73
## stage_min           33 240   0.03   0.01   0.03    0.03   0.01   0.02   0.09
## apex_min            34 240   0.55   0.13   0.54    0.55   0.14   0.13   0.84
## offset_min          35 240   0.38   0.13   0.38    0.38   0.13   0.00   0.73
## onset_min           36 240   0.38   0.12   0.38    0.38   0.11   0.03   0.75
## frame_max           37 240 159.69  51.34 151.00  152.72  37.81  84.00 438.00
## timestamp_max       38 240   3.17   1.03   3.00    3.03   0.76   1.66   8.74
## gaze_angle_x_max    39 240   0.24   0.07   0.24    0.24   0.07   0.02   0.46
## gaze_angle_y_max    40 240   0.41   0.11   0.40    0.41   0.11   0.10   0.69
## pose_Rx_max         41 240   0.21   0.10   0.21    0.21   0.09  -0.10   0.42
## pose_Ry_max         42 240  -0.13   0.08  -0.13   -0.13   0.08  -0.38   0.18
## pose_Rz_max         43 240   0.04   0.08   0.03    0.03   0.06  -0.16   0.33
## AU01_r_max          44 240   0.82   0.60   0.72    0.73   0.42   0.13   5.00
## AU02_r_max          45 240   0.53   0.33   0.47    0.47   0.21   0.13   3.09
## AU04_r_max          46 240   0.50   0.76   0.12    0.34   0.18   0.00   4.10
## AU05_r_max          47 240   0.53   0.35   0.44    0.47   0.25   0.10   2.34
## AU06_r_max          48 240   1.71   0.76   1.68    1.71   0.74   0.00   3.53
## AU07_r_max          49 240   1.67   0.93   1.62    1.64   0.88   0.00   5.00
## AU09_r_max          50 240   0.32   0.17   0.27    0.29   0.13   0.08   0.98
## AU10_r_max          51 240   1.05   0.74   1.07    1.02   0.87   0.00   2.86
## AU12_r_max          52 240   2.77   0.67   2.74    2.78   0.66   0.79   4.70
## AU14_r_max          53 240   1.86   0.43   1.85    1.86   0.47   0.83   2.89
## AU15_r_max          54 240   0.42   0.23   0.36    0.39   0.16   0.13   1.27
## AU17_r_max          55 240   1.25   0.64   1.19    1.17   0.55   0.29   3.97
## AU20_r_max          56 240   0.45   0.24   0.39    0.42   0.19   0.10   1.46
## AU23_r_max          57 240   0.56   0.35   0.48    0.51   0.29   0.09   1.88
## AU25_r_max          58 240   1.40   0.80   1.22    1.34   0.85   0.31   3.38
## AU26_r_max          59 240   1.10   0.48   1.02    1.05   0.42   0.31   2.93
## AU45_r_max          60 240   1.91   1.31   1.91    1.84   1.85   0.22   5.00
## lip_max             61 240 190.26  21.01 191.42  190.83  22.46 126.71 239.26
## eye_max             62 240  12.92   2.15  12.78   12.88   1.78   7.67  19.03
## amplitude_max       63 240   0.64   0.14   0.64    0.64   0.15   0.21   0.96
## stage_max           64 240    Inf    NaN   0.06    0.06   0.02   0.03    Inf
## apex_max            65 240   0.64   0.14   0.64    0.64   0.15   0.21   0.96
## offset_max          66 240   0.53   0.13   0.53    0.53   0.14   0.13   0.84
## onset_max           67 240   0.53   0.13   0.53    0.54   0.14   0.13   0.84
## frame_mean          68 240  80.34  25.67  76.00   76.86  18.90  42.50 219.50
## timestamp_mean      69 240   1.59   0.51   1.50    1.52   0.38   0.83   4.37
## gaze_angle_x_mean   70 240   0.19   0.07   0.20    0.19   0.06  -0.04   0.41
## gaze_angle_y_mean   71 240   0.29   0.08   0.29    0.29   0.07   0.05   0.52
## pose_Rx_mean        72 240   0.17   0.10   0.17    0.17   0.10  -0.11   0.37
## pose_Ry_mean        73 240  -0.16   0.08  -0.17   -0.16   0.07  -0.41   0.05
## pose_Rz_mean        74 240   0.00   0.06   0.00    0.00   0.06  -0.18   0.24
## AU01_r_mean         75 240   0.14   0.13   0.12    0.12   0.07   0.03   1.06
## AU02_r_mean         76 240   0.06   0.04   0.05    0.05   0.02   0.02   0.37
## AU04_r_mean         77 240   0.27   0.59   0.01    0.12   0.01   0.00   3.50
## AU05_r_mean         78 240   0.05   0.03   0.04    0.04   0.02   0.01   0.24
## AU06_r_mean         79 240   0.97   0.58   0.91    0.94   0.53   0.00   2.82
## AU07_r_mean         80 240   0.93   0.78   0.80    0.83   0.67   0.00   4.89
## AU09_r_mean         81 240   0.04   0.02   0.03    0.04   0.02   0.01   0.15
## AU10_r_mean         82 240   0.53   0.48   0.48    0.47   0.53   0.00   2.06
## AU12_r_mean         83 240   1.84   0.57   1.86    1.85   0.56   0.31   3.34
## AU14_r_mean         84 240   1.33   0.41   1.32    1.34   0.42   0.31   2.20
## AU15_r_mean         85 240   0.07   0.04   0.06    0.07   0.03   0.03   0.36
## AU17_r_mean         86 240   0.37   0.20   0.34    0.35   0.17   0.08   1.67
## AU20_r_mean         87 240   0.06   0.04   0.05    0.06   0.03   0.02   0.27
## AU23_r_mean         88 240   0.08   0.06   0.06    0.07   0.04   0.02   0.29
## AU25_r_mean         89 240   0.61   0.44   0.49    0.56   0.43   0.07   1.89
## AU26_r_mean         90 240   0.29   0.14   0.26    0.27   0.11   0.09   1.13
## AU45_r_mean         91 240   0.20   0.14   0.17    0.18   0.13   0.04   0.96
## lip_mean            92 240 176.25  19.78 175.91  176.85  20.89 115.14 220.98
## eye_mean            93 240  10.64   2.04  10.53   10.60   1.56   4.65  16.57
## amplitude_mean      94 240   0.54   0.13   0.54    0.55   0.14   0.13   0.84
## stage_mean          95 240    Inf    NaN   0.04    0.04   0.01   0.02    Inf
## apex_mean           96 240   0.61   0.14   0.61    0.61   0.15   0.19   0.89
## offset_mean         97 240   0.43   0.13   0.43    0.43   0.14   0.03   0.78
## onset_mean          98 240   0.43   0.12   0.43    0.43   0.13   0.04   0.78
## frame_sd            99 240  46.24  14.82  43.73   44.23  10.91  24.39 126.58
## timestamp_sd       100 240   0.92   0.30   0.87    0.88   0.22   0.49   2.53
## gaze_angle_x_sd    101 240   0.02   0.01   0.02    0.02   0.01   0.00   0.10
## gaze_angle_y_sd    102 240   0.04   0.02   0.04    0.04   0.02   0.01   0.12
## pose_Rx_sd         103 240   0.02   0.01   0.02    0.02   0.01   0.01   0.08
## pose_Ry_sd         104 240   0.02   0.01   0.01    0.01   0.01   0.00   0.07
## pose_Rz_sd         105 240   0.02   0.02   0.01    0.02   0.01   0.00   0.14
## AU01_r_sd          106 240   0.22   0.20   0.18    0.19   0.11   0.04   1.78
## AU02_r_sd          107 240   0.12   0.09   0.10    0.10   0.04   0.03   0.80
## AU04_r_sd          108 240   0.09   0.12   0.02    0.07   0.03   0.00   0.59
## AU05_r_sd          109 240   0.11   0.08   0.08    0.10   0.05   0.03   0.61
## AU06_r_sd          110 240   0.59   0.27   0.57    0.59   0.24   0.00   1.31
## AU07_r_sd          111 240   0.42   0.23   0.40    0.41   0.20   0.00   1.15
## AU09_r_sd          112 240   0.08   0.04   0.06    0.07   0.04   0.02   0.25
## AU10_r_sd          113 240   0.36   0.27   0.34    0.35   0.33   0.00   1.12
## AU12_r_sd          114 240   0.92   0.28   0.89    0.90   0.29   0.24   2.05
## AU14_r_sd          115 240   0.34   0.13   0.32    0.33   0.13   0.12   0.82
## AU15_r_sd          116 240   0.11   0.06   0.09    0.10   0.04   0.03   0.46
## AU17_r_sd          117 240   0.39   0.23   0.35    0.36   0.20   0.07   1.49
## AU20_r_sd          118 240   0.11   0.07   0.09    0.10   0.05   0.02   0.42
## AU23_r_sd          119 240   0.14   0.10   0.12    0.13   0.08   0.02   0.51
## AU25_r_sd          120 240   0.51   0.35   0.41    0.47   0.35   0.07   1.44
## AU26_r_sd          121 240   0.32   0.16   0.29    0.30   0.14   0.09   1.08
## AU45_r_sd          122 240   0.41   0.30   0.36    0.39   0.33   0.05   1.50
## lip_sd             123 240  13.83   4.38  13.57   13.70   4.12   2.84  31.30
## eye_sd             124 240   1.53   0.86   1.40    1.46   0.91   0.19   5.10
## amplitude_sd       125 240   0.09   0.03   0.09    0.09   0.03   0.02   0.21
## stage_sd           126 239   0.01   0.01   0.01    0.01   0.00   0.00   0.16
## apex_sd            127 240   0.02   0.01   0.02    0.02   0.01   0.01   0.07
## offset_sd          128 240   0.04   0.02   0.04    0.04   0.02   0.00   0.13
## onset_sd           129 240   0.05   0.02   0.05    0.05   0.02   0.00   0.15
##                    range  skew kurtosis   se
## filename*         239.00  0.00    -1.22 4.48
## subject           523.00  0.09    -1.40 9.99
## gender*             1.00 -0.07    -2.00 0.03
## age                 9.00  0.85     0.00 0.15
## smile_type*         0.00   NaN      NaN 0.00
## frame_min           0.00   NaN      NaN 0.00
## timestamp_min       0.00   NaN      NaN 0.00
## gaze_angle_x_min    0.54 -0.84     1.66 0.01
## gaze_angle_y_min    0.58 -0.27     0.51 0.01
## pose_Rx_min         0.62 -0.70     0.64 0.01
## pose_Ry_min         0.47  0.04     0.28 0.01
## pose_Rz_min         0.36 -0.59     0.07 0.00
## AU01_r_min          0.00   NaN      NaN 0.00
## AU02_r_min          0.00   NaN      NaN 0.00
## AU04_r_min          2.99  4.16    17.86 0.03
## AU05_r_min          0.00   NaN      NaN 0.00
## AU06_r_min          1.35  4.68    23.81 0.01
## AU07_r_min          3.46  3.34    13.33 0.03
## AU09_r_min          0.00   NaN      NaN 0.00
## AU10_r_min          1.64  9.84   105.19 0.01
## AU12_r_min          2.56  3.06    13.73 0.02
## AU14_r_min          1.82  0.53    -0.54 0.03
## AU15_r_min          0.00   NaN      NaN 0.00
## AU17_r_min          0.00   NaN      NaN 0.00
## AU20_r_min          0.00   NaN      NaN 0.00
## AU23_r_min          0.00   NaN      NaN 0.00
## AU25_r_min          0.00   NaN      NaN 0.00
## AU26_r_min          0.00   NaN      NaN 0.00
## AU45_r_min          0.00   NaN      NaN 0.00
## lip_min           109.50  0.07    -0.02 1.18
## eye_min            14.95  0.53    -0.75 0.24
## amplitude_min       0.73  0.07    -0.02 0.01
## stage_min           0.07  2.30     9.11 0.00
## apex_min            0.71 -0.28    -0.29 0.01
## offset_min          0.73  0.02    -0.20 0.01
## onset_min           0.73  0.00     0.12 0.01
## frame_max         354.00  1.90     5.55 3.31
## timestamp_max       7.08  1.90     5.55 0.07
## gaze_angle_x_max    0.44 -0.17     0.35 0.00
## gaze_angle_y_max    0.59  0.20    -0.17 0.01
## pose_Rx_max         0.52 -0.42    -0.09 0.01
## pose_Ry_max         0.56  0.27     0.88 0.01
## pose_Rz_max         0.49  0.89     1.87 0.01
## AU01_r_max          4.87  2.96    13.58 0.04
## AU02_r_max          2.96  3.28    17.31 0.02
## AU04_r_max          4.10  2.17     5.31 0.05
## AU05_r_max          2.24  2.08     6.26 0.02
## AU06_r_max          3.53  0.06    -0.34 0.05
## AU07_r_max          5.00  0.47     0.61 0.06
## AU09_r_max          0.90  1.26     1.38 0.01
## AU10_r_max          2.86  0.13    -0.97 0.05
## AU12_r_max          3.91 -0.09     0.10 0.04
## AU14_r_max          2.06 -0.09    -0.56 0.03
## AU15_r_max          1.14  1.58     2.41 0.01
## AU17_r_max          3.68  1.36     2.79 0.04
## AU20_r_max          1.36  1.32     1.90 0.02
## AU23_r_max          1.79  1.22     1.20 0.02
## AU25_r_max          3.07  0.59    -0.69 0.05
## AU26_r_max          2.62  1.04     1.10 0.03
## AU45_r_max          4.78  0.27    -1.22 0.08
## lip_max           112.55 -0.23    -0.18 1.36
## eye_max            11.36  0.21     0.15 0.14
## amplitude_max       0.75 -0.23    -0.18 0.01
## stage_max            Inf   NaN      NaN  NaN
## apex_max            0.75 -0.23    -0.18 0.01
## offset_max          0.71 -0.21    -0.30 0.01
## onset_max           0.70 -0.27    -0.29 0.01
## frame_mean        177.00  1.90     5.55 1.66
## timestamp_mean      3.54  1.90     5.55 0.03
## gaze_angle_x_mean   0.45 -0.30     0.73 0.00
## gaze_angle_y_mean   0.47 -0.11     0.36 0.01
## pose_Rx_mean        0.48 -0.47    -0.18 0.01
## pose_Ry_mean        0.45  0.09     0.33 0.00
## pose_Rz_mean        0.42  0.04     0.55 0.00
## AU01_r_mean         1.03  4.32    24.41 0.01
## AU02_r_mean         0.36  4.22    23.97 0.00
## AU04_r_mean         3.50  3.22    11.30 0.04
## AU05_r_mean         0.23  2.64    10.95 0.00
## AU06_r_mean         2.82  0.55    -0.08 0.04
## AU07_r_mean         4.89  1.43     3.47 0.05
## AU09_r_mean         0.14  1.49     2.66 0.00
## AU10_r_mean         2.06  0.82     0.16 0.03
## AU12_r_mean         3.03 -0.04    -0.19 0.04
## AU14_r_mean         1.89 -0.19    -0.62 0.03
## AU15_r_mean         0.34  2.78    13.00 0.00
## AU17_r_mean         1.60  1.90     7.24 0.01
## AU20_r_mean         0.26  1.98     4.95 0.00
## AU23_r_mean         0.27  1.51     2.08 0.00
## AU25_r_mean         1.82  0.84    -0.17 0.03
## AU26_r_mean         1.04  1.86     6.04 0.01
## AU45_r_mean         0.92  1.58     4.24 0.01
## lip_mean          105.84 -0.26    -0.30 1.28
## eye_mean           11.92  0.25     0.52 0.13
## amplitude_mean      0.71 -0.26    -0.30 0.01
## stage_mean           Inf   NaN      NaN  NaN
## apex_mean           0.70 -0.24    -0.33 0.01
## offset_mean         0.75 -0.07    -0.21 0.01
## onset_mean          0.74 -0.18     0.08 0.01
## frame_sd          102.19  1.90     5.55 0.96
## timestamp_sd        2.04  1.90     5.55 0.02
## gaze_angle_x_sd     0.10  2.65     9.71 0.00
## gaze_angle_y_sd     0.11  1.07     1.99 0.00
## pose_Rx_sd          0.08  1.52     2.72 0.00
## pose_Ry_sd          0.07  2.36     6.50 0.00
## pose_Rz_sd          0.14  2.30     5.81 0.00
## AU01_r_sd           1.74  4.10    23.08 0.01
## AU02_r_sd           0.77  3.81    20.22 0.01
## AU04_r_sd           0.59  1.49     1.80 0.01
## AU05_r_sd           0.58  2.40     8.93 0.01
## AU06_r_sd           1.31  0.04    -0.30 0.02
## AU07_r_sd           1.15  0.28    -0.07 0.02
## AU09_r_sd           0.23  1.28     1.28 0.00
## AU10_r_sd           1.12  0.30    -0.82 0.02
## AU12_r_sd           1.81  0.61     0.97 0.02
## AU14_r_sd           0.70  0.62     0.14 0.01
## AU15_r_sd           0.43  2.07     5.60 0.00
## AU17_r_sd           1.42  1.56     3.86 0.01
## AU20_r_sd           0.39  1.72     3.08 0.00
## AU23_r_sd           0.49  1.32     1.34 0.01
## AU25_r_sd           1.37  0.74    -0.45 0.02
## AU26_r_sd           1.00  1.32     2.53 0.01
## AU45_r_sd           1.46  0.79     0.27 0.02
## lip_sd             28.46  0.53     1.09 0.28
## eye_sd              4.91  0.87     1.10 0.06
## amplitude_sd        0.19  0.53     1.09 0.00
## stage_sd            0.16  9.06   109.53 0.00
## apex_sd             0.07  1.45     5.25 0.00
## offset_sd           0.13  0.80     0.97 0.00
## onset_sd            0.15  0.71     0.90 0.00
## ------------------------------------------------------------ 
## group: spontaneous
##                   vars   n   mean     sd median trimmed    mad    min    max
## filename*            1 235 118.00  67.98 118.00  118.00  87.47   1.00 235.00
## subject              2 235 283.17 148.56 258.00  280.91 195.70  20.00 534.00
## gender*              3 235   1.52   0.50   2.00    1.52   0.00   1.00   2.00
## age                  4 235  10.76   2.30  10.00   10.49   1.48   8.00  17.00
## smile_type*          5 235   1.00   0.00   1.00    1.00   0.00   1.00   1.00
## frame_min            6 235   1.00   0.00   1.00    1.00   0.00   1.00   1.00
## timestamp_min        7 235   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## gaze_angle_x_min     8 235   0.15   0.08   0.17    0.16   0.07  -0.13   0.39
## gaze_angle_y_min     9 235   0.20   0.09   0.20    0.20   0.08  -0.13   0.48
## pose_Rx_min         10 235   0.09   0.11   0.11    0.10   0.10  -0.37   0.31
## pose_Ry_min         11 235  -0.20   0.09  -0.20   -0.20   0.08  -0.46   0.04
## pose_Rz_min         12 235  -0.05   0.08  -0.04   -0.04   0.08  -0.38   0.13
## AU01_r_min          13 235   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU02_r_min          14 235   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU04_r_min          15 235   0.14   0.45   0.00    0.02   0.00   0.00   3.36
## AU05_r_min          16 235   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU06_r_min          17 235   0.08   0.23   0.00    0.02   0.00   0.00   1.82
## AU07_r_min          18 235   0.24   0.52   0.00    0.11   0.00   0.00   3.59
## AU09_r_min          19 235   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU10_r_min          20 235   0.03   0.13   0.00    0.00   0.00   0.00   0.86
## AU12_r_min          21 235   0.30   0.43   0.05    0.21   0.07   0.00   1.95
## AU14_r_min          22 235   0.56   0.44   0.53    0.52   0.53   0.00   1.85
## AU15_r_min          23 235   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU17_r_min          24 235   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU20_r_min          25 235   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU23_r_min          26 235   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU25_r_min          27 235   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU26_r_min          28 235   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU45_r_min          29 235   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## lip_min             30 235 149.10  17.74 149.13  148.93  17.14 101.23 189.97
## eye_min             31 235   5.67   3.47   4.70    5.43   3.65   0.35  15.45
## amplitude_min       32 235   0.36   0.12   0.36    0.36   0.11   0.04   0.63
## stage_min           33 235   0.03   0.01   0.03    0.03   0.01   0.02   0.09
## apex_min            34 235   0.53   0.13   0.54    0.53   0.14   0.16   0.90
## offset_min          35 235   0.40   0.12   0.40    0.40   0.13   0.09   0.65
## onset_min           36 235   0.38   0.12   0.38    0.38   0.12   0.04   0.74
## frame_max           37 235 244.70 105.60 224.00  234.26  93.40  55.00 705.00
## timestamp_max       38 235   4.87   2.11   4.46    4.67   1.87   1.08  14.08
## gaze_angle_x_max    39 235   0.25   0.07   0.25    0.25   0.07   0.02   0.47
## gaze_angle_y_max    40 235   0.40   0.11   0.41    0.41   0.12   0.07   0.62
## pose_Rx_max         41 235   0.22   0.09   0.22    0.22   0.08  -0.06   0.45
## pose_Ry_max         42 235  -0.13   0.09  -0.13   -0.13   0.09  -0.40   0.11
## pose_Rz_max         43 235   0.05   0.08   0.05    0.04   0.07  -0.11   0.30
## AU01_r_max          44 235   0.73   0.53   0.59    0.64   0.34   0.15   4.52
## AU02_r_max          45 235   0.59   0.40   0.46    0.51   0.22   0.16   2.24
## AU04_r_max          46 235   0.64   0.87   0.29    0.46   0.43   0.00   4.49
## AU05_r_max          47 235   0.51   0.27   0.46    0.48   0.24   0.12   2.01
## AU06_r_max          48 235   1.89   0.77   1.85    1.88   0.74   0.00   3.74
## AU07_r_max          49 235   1.94   0.99   1.89    1.90   0.92   0.00   5.00
## AU09_r_max          50 235   0.39   0.25   0.32    0.35   0.16   0.08   1.88
## AU10_r_max          51 235   1.37   0.74   1.40    1.37   0.76   0.00   3.34
## AU12_r_max          52 235   2.79   0.59   2.84    2.82   0.58   1.19   4.20
## AU14_r_max          53 235   1.85   0.45   1.86    1.85   0.46   0.03   3.43
## AU15_r_max          54 235   0.47   0.27   0.41    0.44   0.18   0.14   2.76
## AU17_r_max          55 235   1.30   0.60   1.21    1.24   0.52   0.30   3.96
## AU20_r_max          56 235   0.50   0.24   0.44    0.47   0.22   0.12   1.61
## AU23_r_max          57 235   0.63   0.38   0.57    0.58   0.34   0.10   1.91
## AU25_r_max          58 235   1.28   0.70   1.09    1.20   0.67   0.32   3.46
## AU26_r_max          59 235   1.18   0.60   1.07    1.10   0.42   0.29   4.73
## AU45_r_max          60 235   1.69   1.09   1.54    1.63   1.45   0.22   4.27
## lip_max             61 235 188.09  20.82 189.16  188.57  22.50 127.31 244.90
## eye_max             62 235  12.57   2.32  12.55   12.53   2.15   7.25  22.05
## amplitude_max       63 235   0.62   0.14   0.63    0.62   0.15   0.22   1.00
## stage_max           64 235   0.06   0.04   0.06    0.06   0.02   0.03   0.48
## apex_max            65 235   0.62   0.14   0.63    0.62   0.15   0.22   1.00
## offset_max          66 235   0.53   0.13   0.53    0.53   0.15   0.15   0.90
## onset_max           67 235   0.53   0.13   0.53    0.53   0.14   0.16   0.89
## frame_mean          68 235 122.85  52.80 112.50  117.63  46.70  28.00 353.00
## timestamp_mean      69 235   2.44   1.06   2.23    2.33   0.93   0.54   7.04
## gaze_angle_x_mean   70 235   0.20   0.07   0.21    0.20   0.06  -0.01   0.43
## gaze_angle_y_mean   71 235   0.28   0.08   0.28    0.28   0.07   0.00   0.50
## pose_Rx_mean        72 235   0.16   0.09   0.17    0.17   0.08  -0.11   0.37
## pose_Ry_mean        73 235  -0.17   0.08  -0.17   -0.17   0.07  -0.43   0.05
## pose_Rz_mean        74 235   0.00   0.07   0.00    0.00   0.07  -0.18   0.19
## AU01_r_mean         75 235   0.12   0.09   0.10    0.10   0.05   0.03   0.95
## AU02_r_mean         76 235   0.06   0.04   0.04    0.05   0.02   0.02   0.29
## AU04_r_mean         77 235   0.31   0.63   0.02    0.16   0.02   0.00   3.75
## AU05_r_mean         78 235   0.04   0.02   0.03    0.04   0.01   0.01   0.12
## AU06_r_mean         79 235   1.08   0.62   0.99    1.04   0.65   0.00   2.95
## AU07_r_mean         80 235   1.08   0.83   0.96    1.00   0.85   0.00   4.76
## AU09_r_mean         81 235   0.05   0.04   0.04    0.04   0.02   0.01   0.30
## AU10_r_mean         82 235   0.72   0.52   0.67    0.70   0.61   0.00   2.13
## AU12_r_mean         83 235   1.91   0.58   1.92    1.92   0.54   0.40   3.40
## AU14_r_mean         84 235   1.30   0.42   1.31    1.31   0.42   0.00   2.81
## AU15_r_mean         85 235   0.08   0.04   0.07    0.07   0.03   0.03   0.30
## AU17_r_mean         86 235   0.36   0.19   0.31    0.33   0.15   0.11   1.06
## AU20_r_mean         87 235   0.07   0.04   0.06    0.06   0.02   0.02   0.32
## AU23_r_mean         88 235   0.08   0.05   0.06    0.07   0.04   0.01   0.32
## AU25_r_mean         89 235   0.46   0.31   0.37    0.42   0.27   0.08   1.70
## AU26_r_mean         90 235   0.31   0.17   0.27    0.29   0.13   0.09   1.41
## AU45_r_mean         91 235   0.16   0.11   0.13    0.15   0.08   0.04   0.63
## lip_mean            92 235 174.40  19.69 175.04  174.72  22.09 118.36 229.63
## eye_mean            93 235  10.29   2.18  10.24   10.23   2.15   5.32  17.31
## amplitude_mean      94 235   0.53   0.13   0.53    0.53   0.15   0.16   0.90
## stage_mean          95 235   0.04   0.02   0.04    0.04   0.01   0.02   0.13
## apex_mean           96 235   0.58   0.14   0.59    0.59   0.15   0.18   0.96
## offset_mean         97 235   0.46   0.13   0.46    0.46   0.14   0.14   0.73
## onset_mean          98 235   0.44   0.12   0.45    0.44   0.14   0.08   0.76
## frame_sd            99 235  70.78  30.48  64.81   67.77  26.96  16.02 203.66
## timestamp_sd       100 235   1.42   0.61   1.30    1.36   0.54   0.32   4.07
## gaze_angle_x_sd    101 235   0.02   0.01   0.02    0.02   0.01   0.00   0.10
## gaze_angle_y_sd    102 235   0.04   0.02   0.04    0.04   0.02   0.01   0.10
## pose_Rx_sd         103 235   0.03   0.02   0.02    0.03   0.01   0.01   0.16
## pose_Ry_sd         104 235   0.02   0.01   0.01    0.02   0.01   0.00   0.09
## pose_Rz_sd         105 235   0.03   0.02   0.02    0.02   0.01   0.00   0.17
## AU01_r_sd          106 235   0.18   0.16   0.14    0.15   0.08   0.04   1.60
## AU02_r_sd          107 235   0.12   0.09   0.09    0.10   0.05   0.03   0.62
## AU04_r_sd          108 235   0.12   0.16   0.05    0.09   0.07   0.00   0.67
## AU05_r_sd          109 235   0.10   0.05   0.08    0.09   0.04   0.03   0.35
## AU06_r_sd          110 235   0.55   0.21   0.54    0.54   0.18   0.00   1.15
## AU07_r_sd          111 235   0.42   0.22   0.41    0.41   0.18   0.00   1.26
## AU09_r_sd          112 235   0.09   0.07   0.07    0.08   0.04   0.02   0.56
## AU10_r_sd          113 235   0.40   0.22   0.41    0.40   0.20   0.00   1.15
## AU12_r_sd          114 235   0.74   0.19   0.72    0.73   0.21   0.32   1.34
## AU14_r_sd          115 235   0.30   0.12   0.27    0.29   0.11   0.01   0.83
## AU15_r_sd          116 235   0.11   0.07   0.10    0.11   0.04   0.04   0.64
## AU17_r_sd          117 235   0.35   0.18   0.32    0.33   0.16   0.08   1.23
## AU20_r_sd          118 235   0.12   0.06   0.10    0.11   0.05   0.03   0.52
## AU23_r_sd          119 235   0.15   0.09   0.13    0.13   0.08   0.03   0.54
## AU25_r_sd          120 235   0.42   0.28   0.33    0.39   0.23   0.07   1.43
## AU26_r_sd          121 235   0.33   0.18   0.29    0.31   0.14   0.07   1.46
## AU45_r_sd          122 235   0.33   0.23   0.28    0.30   0.22   0.05   1.21
## lip_sd             123 235  11.00   3.42  10.82   10.88   3.44   3.98  19.10
## eye_sd             124 235   1.38   0.69   1.27    1.33   0.70   0.23   3.77
## amplitude_sd       125 235   0.07   0.02   0.07    0.07   0.02   0.03   0.13
## stage_sd           126 235   0.01   0.01   0.01    0.01   0.00   0.00   0.10
## apex_sd            127 235   0.02   0.01   0.02    0.02   0.01   0.01   0.05
## offset_sd          128 235   0.04   0.02   0.03    0.04   0.02   0.00   0.14
## onset_sd           129 235   0.04   0.02   0.04    0.04   0.02   0.01   0.12
##                    range  skew kurtosis   se
## filename*         234.00  0.00    -1.22 4.43
## subject           514.00  0.19    -1.28 9.69
## gender*             1.00 -0.08    -2.00 0.03
## age                 9.00  1.00     0.33 0.15
## smile_type*         0.00   NaN      NaN 0.00
## frame_min           0.00   NaN      NaN 0.00
## timestamp_min       0.00   NaN      NaN 0.00
## gaze_angle_x_min    0.52 -0.61     1.46 0.01
## gaze_angle_y_min    0.61 -0.14     1.38 0.01
## pose_Rx_min         0.68 -0.71     0.86 0.01
## pose_Ry_min         0.50 -0.07     0.14 0.01
## pose_Rz_min         0.50 -0.68     1.20 0.01
## AU01_r_min          0.00   NaN      NaN 0.00
## AU02_r_min          0.00   NaN      NaN 0.00
## AU04_r_min          3.36  4.28    20.21 0.03
## AU05_r_min          0.00   NaN      NaN 0.00
## AU06_r_min          1.82  4.11    20.83 0.01
## AU07_r_min          3.59  3.15    11.80 0.03
## AU09_r_min          0.00   NaN      NaN 0.00
## AU10_r_min          0.86  4.29    18.95 0.01
## AU12_r_min          1.95  1.58     1.74 0.03
## AU14_r_min          1.85  0.47    -0.65 0.03
## AU15_r_min          0.00   NaN      NaN 0.00
## AU17_r_min          0.00   NaN      NaN 0.00
## AU20_r_min          0.00   NaN      NaN 0.00
## AU23_r_min          0.00   NaN      NaN 0.00
## AU25_r_min          0.00   NaN      NaN 0.00
## AU26_r_min          0.00   NaN      NaN 0.00
## AU45_r_min          0.00   NaN      NaN 0.00
## lip_min            88.74  0.04    -0.40 1.16
## eye_min            15.10  0.57    -0.68 0.23
## amplitude_min       0.59  0.04    -0.40 0.01
## stage_min           0.07  2.43     9.81 0.00
## apex_min            0.75 -0.16    -0.32 0.01
## offset_min          0.55 -0.03    -0.68 0.01
## onset_min           0.70  0.07    -0.15 0.01
## frame_max         650.00  1.17     1.98 6.89
## timestamp_max      13.00  1.17     1.98 0.14
## gaze_angle_x_max    0.44 -0.05     0.57 0.00
## gaze_angle_y_max    0.55 -0.22    -0.39 0.01
## pose_Rx_max         0.51 -0.48     0.25 0.01
## pose_Ry_max         0.51 -0.02    -0.13 0.01
## pose_Rz_max         0.42  0.49     0.38 0.01
## AU01_r_max          4.37  2.92    13.47 0.03
## AU02_r_max          2.08  2.02     4.19 0.03
## AU04_r_max          4.49  1.81     3.22 0.06
## AU05_r_max          1.89  1.86     5.70 0.02
## AU06_r_max          3.74  0.10    -0.16 0.05
## AU07_r_max          5.00  0.50     0.45 0.06
## AU09_r_max          1.80  2.43     8.56 0.02
## AU10_r_max          3.34  0.04    -0.35 0.05
## AU12_r_max          3.01 -0.33    -0.07 0.04
## AU14_r_max          3.40 -0.27     1.13 0.03
## AU15_r_max          2.62  3.53    23.08 0.02
## AU17_r_max          3.66  1.17     2.29 0.04
## AU20_r_max          1.49  1.27     2.14 0.02
## AU23_r_max          1.81  1.19     1.27 0.02
## AU25_r_max          3.14  0.91     0.16 0.05
## AU26_r_max          4.44  1.97     6.50 0.04
## AU45_r_max          4.05  0.31    -1.24 0.07
## lip_max           117.59 -0.25    -0.24 1.36
## eye_max            14.80  0.38     1.12 0.15
## amplitude_max       0.78 -0.25    -0.24 0.01
## stage_max           0.45  6.04    56.02 0.00
## apex_max            0.78 -0.25    -0.24 0.01
## offset_max          0.74 -0.16    -0.35 0.01
## onset_max           0.73 -0.17    -0.35 0.01
## frame_mean        325.00  1.17     1.98 3.44
## timestamp_mean      6.50  1.17     1.98 0.07
## gaze_angle_x_mean   0.44 -0.04     0.53 0.00
## gaze_angle_y_mean   0.51 -0.20     1.00 0.00
## pose_Rx_mean        0.48 -0.47     0.11 0.01
## pose_Ry_mean        0.48 -0.08     0.07 0.01
## pose_Rz_mean        0.36  0.10    -0.41 0.00
## AU01_r_mean         0.92  4.32    29.72 0.01
## AU02_r_mean         0.27  3.07    10.93 0.00
## AU04_r_mean         3.75  2.80     8.51 0.04
## AU05_r_mean         0.11  1.66     3.35 0.00
## AU06_r_mean         2.95  0.56     0.02 0.04
## AU07_r_mean         4.76  1.11     1.82 0.05
## AU09_r_mean         0.29  3.55    17.18 0.00
## AU10_r_mean         2.13  0.40    -0.74 0.03
## AU12_r_mean         2.99 -0.09    -0.15 0.04
## AU14_r_mean         2.80 -0.19     0.44 0.03
## AU15_r_mean         0.26  2.04     5.97 0.00
## AU17_r_mean         0.94  1.29     1.67 0.01
## AU20_r_mean         0.30  2.62    11.87 0.00
## AU23_r_mean         0.30  1.57     3.25 0.00
## AU25_r_mean         1.61  1.28     1.67 0.02
## AU26_r_mean         1.32  2.37     9.87 0.01
## AU45_r_mean         0.59  1.59     2.74 0.01
## lip_mean          111.27 -0.17    -0.33 1.28
## eye_mean           11.98  0.38     0.35 0.14
## amplitude_mean      0.74 -0.17    -0.33 0.01
## stage_mean          0.11  2.76    11.95 0.00
## apex_mean           0.77 -0.21    -0.28 0.01
## offset_mean         0.60 -0.10    -0.57 0.01
## onset_mean          0.68 -0.12    -0.32 0.01
## frame_sd          187.64  1.17     1.98 1.99
## timestamp_sd        3.75  1.17     1.98 0.04
## gaze_angle_x_sd     0.09  2.71    11.41 0.00
## gaze_angle_y_sd     0.09  0.91     0.93 0.00
## pose_Rx_sd          0.15  2.20     6.91 0.00
## pose_Ry_sd          0.09  2.12     6.17 0.00
## pose_Rz_sd          0.16  2.74    10.42 0.00
## AU01_r_sd           1.56  4.42    31.16 0.01
## AU02_r_sd           0.59  2.66     8.05 0.01
## AU04_r_sd           0.67  1.57     2.06 0.01
## AU05_r_sd           0.32  1.86     4.41 0.00
## AU06_r_sd           1.15  0.10     0.33 0.01
## AU07_r_sd           1.26  0.66     1.12 0.01
## AU09_r_sd           0.54  3.27    15.18 0.00
## AU10_r_sd           1.15  0.19     0.26 0.01
## AU12_r_sd           1.02  0.29    -0.34 0.01
## AU14_r_sd           0.82  0.85     1.04 0.01
## AU15_r_sd           0.60  3.06    17.11 0.00
## AU17_r_sd           1.14  1.49     3.38 0.01
## AU20_r_sd           0.49  2.10     7.71 0.00
## AU23_r_sd           0.52  1.27     1.73 0.01
## AU25_r_sd           1.36  1.02     0.35 0.02
## AU26_r_sd           1.39  2.05     7.43 0.01
## AU45_r_sd           1.16  1.02     0.72 0.01
## lip_sd             15.12  0.31    -0.51 0.22
## eye_sd              3.54  0.75     0.46 0.05
## amplitude_sd        0.10  0.31    -0.51 0.00
## stage_sd            0.09  7.06    73.80 0.00
## apex_sd             0.05  0.74     0.37 0.00
## offset_sd           0.14  1.41     2.75 0.00
## onset_sd            0.11  0.85     0.59 0.00
# descriptive statistics per classifier and boys/girls
desc_stats_class_gender <- describeBy(UvA_sum ~ smile_type + gender)
desc_stats_class_gender
## 
##  Descriptive statistics by group 
## smile_type: deliberate 
## gender: female
##                   vars   n   mean     sd median trimmed    mad    min    max
## filename*            1 116  58.50  33.63  58.50   58.50  43.00   1.00 116.00
## subject              2 116 282.35 158.93 252.00  279.59 189.77  20.00 543.00
## gender*              3 116   1.00   0.00   1.00    1.00   0.00   1.00   1.00
## age                  4 116  11.46   2.51  11.00   11.28   2.97   8.00  17.00
## smile_type*          5 116   1.00   0.00   1.00    1.00   0.00   1.00   1.00
## frame_min            6 116   1.00   0.00   1.00    1.00   0.00   1.00   1.00
## timestamp_min        7 116   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## gaze_angle_x_min     8 116   0.14   0.08   0.15    0.14   0.07  -0.17   0.26
## gaze_angle_y_min     9 116   0.21   0.08   0.22    0.21   0.08  -0.01   0.48
## pose_Rx_min         10 116   0.13   0.09   0.14    0.13   0.10  -0.10   0.29
## pose_Ry_min         11 116  -0.18   0.07  -0.20   -0.18   0.08  -0.39   0.03
## pose_Rz_min         12 116  -0.04   0.06  -0.03   -0.03   0.06  -0.22   0.09
## AU01_r_min          13 116   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU02_r_min          14 116   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU04_r_min          15 116   0.16   0.54   0.00    0.02   0.00   0.00   2.99
## AU05_r_min          16 116   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU06_r_min          17 116   0.06   0.18   0.00    0.01   0.00   0.00   1.35
## AU07_r_min          18 116   0.27   0.56   0.00    0.14   0.00   0.00   3.46
## AU09_r_min          19 116   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU10_r_min          20 116   0.03   0.19   0.00    0.00   0.00   0.00   1.64
## AU12_r_min          21 116   0.24   0.38   0.00    0.16   0.00   0.00   2.56
## AU14_r_min          22 116   0.57   0.39   0.57    0.55   0.42   0.00   1.44
## AU15_r_min          23 116   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU17_r_min          24 116   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU20_r_min          25 116   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU23_r_min          26 116   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU25_r_min          27 116   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU26_r_min          28 116   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU45_r_min          29 116   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## lip_min             30 116 150.76  19.36 148.81  150.74  20.95  95.03 204.53
## eye_min             31 116   5.80   3.29   5.31    5.68   4.16   0.54  14.01
## amplitude_min       32 116   0.37   0.13   0.36    0.37   0.14   0.00   0.73
## stage_min           33 116   0.03   0.01   0.03    0.03   0.01   0.02   0.09
## apex_min            34 116   0.56   0.14   0.54    0.56   0.14   0.13   0.84
## offset_min          35 116   0.40   0.14   0.39    0.39   0.15   0.00   0.73
## onset_min           36 116   0.40   0.13   0.39    0.40   0.12   0.03   0.75
## frame_max           37 116 155.22  49.30 151.00  148.67  35.58  84.00 438.00
## timestamp_max       38 116   3.08   0.99   3.00    2.95   0.71   1.66   8.74
## gaze_angle_x_max    39 116   0.24   0.06   0.24    0.24   0.07   0.11   0.39
## gaze_angle_y_max    40 116   0.42   0.10   0.41    0.41   0.10   0.19   0.68
## pose_Rx_max         41 116   0.22   0.09   0.21    0.22   0.09   0.00   0.42
## pose_Ry_max         42 116  -0.12   0.07  -0.13   -0.12   0.08  -0.27   0.18
## pose_Rz_max         43 116   0.05   0.08   0.04    0.05   0.07  -0.14   0.33
## AU01_r_max          44 116   0.81   0.44   0.73    0.76   0.40   0.20   2.85
## AU02_r_max          45 116   0.50   0.25   0.47    0.47   0.21   0.13   1.60
## AU04_r_max          46 116   0.55   0.82   0.27    0.38   0.40   0.00   4.10
## AU05_r_max          47 116   0.52   0.35   0.42    0.47   0.27   0.10   2.34
## AU06_r_max          48 116   1.94   0.68   1.95    1.92   0.77   0.49   3.49
## AU07_r_max          49 116   1.85   0.93   1.83    1.83   0.81   0.01   5.00
## AU09_r_max          50 116   0.31   0.15   0.28    0.29   0.13   0.08   0.77
## AU10_r_max          51 116   1.31   0.73   1.33    1.31   0.76   0.00   2.86
## AU12_r_max          52 116   2.89   0.59   2.90    2.89   0.60   1.40   4.12
## AU14_r_max          53 116   1.86   0.39   1.84    1.87   0.43   1.02   2.70
## AU15_r_max          54 116   0.42   0.23   0.35    0.39   0.15   0.15   1.27
## AU17_r_max          55 116   1.33   0.64   1.27    1.25   0.49   0.29   3.72
## AU20_r_max          56 116   0.48   0.24   0.42    0.45   0.19   0.16   1.24
## AU23_r_max          57 116   0.59   0.36   0.54    0.55   0.36   0.09   1.88
## AU25_r_max          58 116   1.49   0.83   1.33    1.43   0.90   0.31   3.38
## AU26_r_max          59 116   1.12   0.48   1.02    1.07   0.44   0.31   2.86
## AU45_r_max          60 116   1.89   1.28   1.84    1.83   1.77   0.25   4.73
## lip_max             61 116 191.46  21.38 191.42  192.86  22.34 126.71 232.87
## eye_max             62 116  12.86   2.03  12.64   12.81   1.65   7.67  18.57
## amplitude_max       63 116   0.64   0.14   0.64    0.65   0.15   0.21   0.92
## stage_max           64 116    Inf    NaN   0.06    0.06   0.02   0.03    Inf
## apex_max            65 116   0.64   0.14   0.64    0.65   0.15   0.21   0.92
## offset_max          66 116   0.54   0.14   0.53    0.55   0.15   0.13   0.84
## onset_max           67 116   0.54   0.14   0.53    0.55   0.14   0.13   0.84
## frame_mean          68 116  78.11  24.65  76.00   74.84  17.79  42.50 219.50
## timestamp_mean      69 116   1.54   0.49   1.50    1.48   0.36   0.83   4.37
## gaze_angle_x_mean   70 116   0.19   0.06   0.20    0.19   0.06   0.06   0.30
## gaze_angle_y_mean   71 116   0.29   0.08   0.29    0.29   0.06   0.12   0.52
## pose_Rx_mean        72 116   0.18   0.09   0.18    0.18   0.10  -0.03   0.37
## pose_Ry_mean        73 116  -0.15   0.07  -0.17   -0.15   0.07  -0.32   0.05
## pose_Rz_mean        74 116   0.01   0.06   0.01    0.01   0.06  -0.16   0.24
## AU01_r_mean         75 116   0.14   0.08   0.13    0.13   0.08   0.03   0.45
## AU02_r_mean         76 116   0.05   0.03   0.05    0.05   0.02   0.02   0.20
## AU04_r_mean         77 116   0.30   0.66   0.02    0.15   0.03   0.00   3.50
## AU05_r_mean         78 116   0.05   0.03   0.04    0.04   0.02   0.01   0.24
## AU06_r_mean         79 116   1.14   0.58   1.08    1.11   0.65   0.09   2.82
## AU07_r_mean         80 116   1.08   0.84   0.98    1.00   0.78   0.00   4.89
## AU09_r_mean         81 116   0.04   0.02   0.03    0.04   0.02   0.01   0.13
## AU10_r_mean         82 116   0.70   0.51   0.72    0.67   0.56   0.00   2.06
## AU12_r_mean         83 116   1.97   0.56   1.93    1.96   0.61   0.78   3.34
## AU14_r_mean         84 116   1.34   0.37   1.31    1.35   0.40   0.46   2.13
## AU15_r_mean         85 116   0.07   0.04   0.06    0.07   0.03   0.03   0.24
## AU17_r_mean         86 116   0.40   0.22   0.35    0.36   0.14   0.11   1.67
## AU20_r_mean         87 116   0.07   0.04   0.06    0.07   0.03   0.02   0.27
## AU23_r_mean         88 116   0.09   0.06   0.07    0.08   0.04   0.02   0.28
## AU25_r_mean         89 116   0.67   0.46   0.59    0.63   0.52   0.08   1.89
## AU26_r_mean         90 116   0.29   0.15   0.26    0.27   0.11   0.10   1.13
## AU45_r_mean         91 116   0.20   0.14   0.18    0.19   0.14   0.04   0.96
## lip_mean            92 116 177.74  20.65 175.98  178.86  21.06 115.14 220.98
## eye_mean            93 116  10.56   1.85  10.54   10.61   1.40   4.65  16.01
## amplitude_mean      94 116   0.55   0.14   0.54    0.56   0.14   0.13   0.84
## stage_mean          95 116    Inf    NaN   0.04    0.04   0.01   0.02    Inf
## apex_mean           96 116   0.62   0.14   0.61    0.63   0.15   0.19   0.89
## offset_mean         97 116   0.45   0.14   0.43    0.45   0.15   0.03   0.78
## onset_mean          98 116   0.44   0.13   0.44    0.45   0.13   0.04   0.78
## frame_sd            99 116  44.95  14.23  43.73   43.06  10.27  24.39 126.58
## timestamp_sd       100 116   0.90   0.28   0.87    0.86   0.21   0.49   2.53
## gaze_angle_x_sd    101 116   0.02   0.02   0.02    0.02   0.01   0.01   0.10
## gaze_angle_y_sd    102 116   0.04   0.02   0.04    0.04   0.02   0.01   0.12
## pose_Rx_sd         103 116   0.02   0.01   0.02    0.02   0.01   0.01   0.07
## pose_Ry_sd         104 116   0.02   0.01   0.01    0.01   0.01   0.00   0.07
## pose_Rz_sd         105 116   0.03   0.03   0.02    0.02   0.01   0.00   0.14
## AU01_r_sd          106 116   0.22   0.12   0.20    0.20   0.13   0.04   0.80
## AU02_r_sd          107 116   0.11   0.07   0.10    0.10   0.05   0.03   0.44
## AU04_r_sd          108 116   0.10   0.12   0.04    0.07   0.07   0.00   0.59
## AU05_r_sd          109 116   0.11   0.08   0.08    0.10   0.05   0.03   0.61
## AU06_r_sd          110 116   0.66   0.23   0.66    0.65   0.27   0.14   1.31
## AU07_r_sd          111 116   0.44   0.22   0.43    0.44   0.19   0.00   1.02
## AU09_r_sd          112 116   0.08   0.04   0.07    0.07   0.04   0.02   0.22
## AU10_r_sd          113 116   0.45   0.27   0.44    0.45   0.30   0.00   1.12
## AU12_r_sd          114 116   0.91   0.26   0.88    0.90   0.28   0.41   1.61
## AU14_r_sd          115 116   0.33   0.12   0.31    0.32   0.13   0.13   0.72
## AU15_r_sd          116 116   0.11   0.06   0.09    0.10   0.04   0.04   0.38
## AU17_r_sd          117 116   0.42   0.24   0.38    0.39   0.15   0.08   1.49
## AU20_r_sd          118 116   0.13   0.08   0.10    0.11   0.06   0.04   0.42
## AU23_r_sd          119 116   0.16   0.10   0.13    0.14   0.09   0.02   0.45
## AU25_r_sd          120 116   0.55   0.37   0.46    0.52   0.36   0.08   1.44
## AU26_r_sd          121 116   0.33   0.17   0.29    0.31   0.13   0.09   1.08
## AU45_r_sd          122 116   0.41   0.29   0.35    0.39   0.33   0.06   1.50
## lip_sd             123 116  13.43   3.81  13.54   13.45   4.07   5.64  21.98
## eye_sd             124 116   1.52   0.81   1.37    1.45   0.83   0.20   4.24
## amplitude_sd       125 116   0.09   0.03   0.09    0.09   0.03   0.04   0.15
## stage_sd           126 115   0.01   0.02   0.01    0.01   0.00   0.00   0.16
## apex_sd            127 116   0.02   0.01   0.02    0.02   0.01   0.01   0.04
## offset_sd          128 116   0.04   0.02   0.04    0.04   0.02   0.01   0.10
## onset_sd           129 116   0.05   0.02   0.05    0.05   0.02   0.00   0.10
##                    range  skew kurtosis    se
## filename*         115.00  0.00    -1.23  3.12
## subject           523.00  0.22    -1.29 14.76
## gender*             0.00   NaN      NaN  0.00
## age                 9.00  0.58    -0.58  0.23
## smile_type*         0.00   NaN      NaN  0.00
## frame_min           0.00   NaN      NaN  0.00
## timestamp_min       0.00   NaN      NaN  0.00
## gaze_angle_x_min    0.44 -1.20     2.05  0.01
## gaze_angle_y_min    0.49  0.15     0.78  0.01
## pose_Rx_min         0.39 -0.25    -0.67  0.01
## pose_Ry_min         0.42  0.21    -0.03  0.01
## pose_Rz_min         0.32 -0.45    -0.09  0.01
## AU01_r_min          0.00   NaN      NaN  0.00
## AU02_r_min          0.00   NaN      NaN  0.00
## AU04_r_min          2.99  4.21    17.22  0.05
## AU05_r_min          0.00   NaN      NaN  0.00
## AU06_r_min          1.35  4.47    24.86  0.02
## AU07_r_min          3.46  2.83    10.14  0.05
## AU09_r_min          0.00   NaN      NaN  0.00
## AU10_r_min          1.64  6.85    49.77  0.02
## AU12_r_min          2.56  2.70    11.12  0.04
## AU14_r_min          1.44  0.14    -0.86  0.04
## AU15_r_min          0.00   NaN      NaN  0.00
## AU17_r_min          0.00   NaN      NaN  0.00
## AU20_r_min          0.00   NaN      NaN  0.00
## AU23_r_min          0.00   NaN      NaN  0.00
## AU25_r_min          0.00   NaN      NaN  0.00
## AU26_r_min          0.00   NaN      NaN  0.00
## AU45_r_min          0.00   NaN      NaN  0.00
## lip_min           109.50  0.04     0.11  1.80
## eye_min            13.47  0.30    -1.12  0.31
## amplitude_min       0.73  0.04     0.11  0.01
## stage_min           0.07  2.81    11.05  0.00
## apex_min            0.71 -0.48    -0.03  0.01
## offset_min          0.73  0.00    -0.13  0.01
## onset_min           0.73 -0.16     0.34  0.01
## frame_max         354.00  2.47     9.87  4.58
## timestamp_max       7.08  2.47     9.87  0.09
## gaze_angle_x_max    0.28 -0.02    -0.60  0.01
## gaze_angle_y_max    0.49  0.28    -0.45  0.01
## pose_Rx_max         0.42  0.03    -0.54  0.01
## pose_Ry_max         0.45  0.77     1.36  0.01
## pose_Rz_max         0.48  1.03     2.06  0.01
## AU01_r_max          2.65  1.32     2.96  0.04
## AU02_r_max          1.47  1.77     4.61  0.02
## AU04_r_max          4.10  2.48     6.79  0.08
## AU05_r_max          2.24  1.91     5.75  0.03
## AU06_r_max          3.00  0.21    -0.60  0.06
## AU07_r_max          4.99  0.46     1.02  0.09
## AU09_r_max          0.69  0.89     0.18  0.01
## AU10_r_max          2.86 -0.10    -0.76  0.07
## AU12_r_max          2.72 -0.07    -0.40  0.05
## AU14_r_max          1.68 -0.06    -0.73  0.04
## AU15_r_max          1.12  1.54     2.38  0.02
## AU17_r_max          3.43  1.38     2.67  0.06
## AU20_r_max          1.08  1.10     0.74  0.02
## AU23_r_max          1.79  1.10     0.91  0.03
## AU25_r_max          3.07  0.51    -0.79  0.08
## AU26_r_max          2.55  0.96     0.93  0.04
## AU45_r_max          4.48  0.22    -1.33  0.12
## lip_max           106.16 -0.54     0.11  1.98
## eye_max            10.90  0.24     0.28  0.19
## amplitude_max       0.71 -0.54     0.11  0.01
## stage_max            Inf   NaN      NaN   NaN
## apex_max            0.71 -0.54     0.11  0.01
## offset_max          0.71 -0.43    -0.02  0.01
## onset_max           0.70 -0.47     0.00  0.01
## frame_mean        177.00  2.47     9.87  2.29
## timestamp_mean      3.54  2.47     9.87  0.05
## gaze_angle_x_mean   0.24 -0.26    -0.76  0.01
## gaze_angle_y_mean   0.40  0.52     0.51  0.01
## pose_Rx_mean        0.40 -0.05    -0.60  0.01
## pose_Ry_mean        0.36  0.34    -0.09  0.01
## pose_Rz_mean        0.40  0.28     1.15  0.01
## AU01_r_mean         0.42  1.26     2.26  0.01
## AU02_r_mean         0.18  2.56     8.08  0.00
## AU04_r_mean         3.50  3.35    11.65  0.06
## AU05_r_mean         0.22  2.54    10.89  0.00
## AU06_r_mean         2.73  0.49    -0.41  0.05
## AU07_r_mean         4.89  1.44     3.69  0.08
## AU09_r_mean         0.12  1.38     1.98  0.00
## AU10_r_mean         2.06  0.52    -0.40  0.05
## AU12_r_mean         2.56  0.10    -0.39  0.05
## AU14_r_mean         1.67 -0.06    -0.64  0.03
## AU15_r_mean         0.21  1.91     4.99  0.00
## AU17_r_mean         1.56  2.47     9.80  0.02
## AU20_r_mean         0.25  1.83     3.92  0.00
## AU23_r_mean         0.27  1.30     1.22  0.01
## AU25_r_mean         1.81  0.65    -0.54  0.04
## AU26_r_mean         1.03  2.32     8.85  0.01
## AU45_r_mean         0.91  1.80     5.69  0.01
## lip_mean          105.84 -0.47    -0.04  1.92
## eye_mean           11.36 -0.20     0.83  0.17
## amplitude_mean      0.71 -0.47    -0.04  0.01
## stage_mean           Inf   NaN      NaN   NaN
## apex_mean           0.70 -0.52    -0.08  0.01
## offset_mean         0.75 -0.15     0.09  0.01
## onset_mean          0.74 -0.33     0.40  0.01
## frame_sd          102.19  2.47     9.87  1.32
## timestamp_sd        2.04  2.47     9.87  0.03
## gaze_angle_x_sd     0.10  2.43     7.90  0.00
## gaze_angle_y_sd     0.11  0.83     1.18  0.00
## pose_Rx_sd          0.06  1.16     1.04  0.00
## pose_Ry_sd          0.07  2.04     4.45  0.00
## pose_Rz_sd          0.14  2.25     5.42  0.00
## AU01_r_sd           0.76  1.36     3.47  0.01
## AU02_r_sd           0.41  2.51     7.97  0.01
## AU04_r_sd           0.59  1.68     2.93  0.01
## AU05_r_sd           0.58  2.46    10.38  0.01
## AU06_r_sd           1.18  0.23    -0.50  0.02
## AU07_r_sd           1.02  0.19    -0.03  0.02
## AU09_r_sd           0.21  1.17     1.09  0.00
## AU10_r_sd           1.12  0.02    -0.74  0.02
## AU12_r_sd           1.21  0.60    -0.23  0.02
## AU14_r_sd           0.58  0.75     0.33  0.01
## AU15_r_sd           0.34  1.90     4.48  0.01
## AU17_r_sd           1.41  1.89     5.13  0.02
## AU20_r_sd           0.38  1.55     2.10  0.01
## AU23_r_sd           0.43  1.10     0.48  0.01
## AU25_r_sd           1.36  0.63    -0.68  0.03
## AU26_r_sd           0.99  1.55     3.67  0.02
## AU45_r_sd           1.44  0.81     0.47  0.03
## lip_sd             16.35 -0.01    -0.77  0.35
## eye_sd              4.03  0.77     0.24  0.08
## amplitude_sd        0.11 -0.01    -0.77  0.00
## stage_sd            0.16  8.92    86.69  0.00
## apex_sd             0.04  0.37    -0.42  0.00
## offset_sd           0.09  0.42     0.19  0.00
## onset_sd            0.10  0.30    -0.17  0.00
## ------------------------------------------------------------ 
## smile_type: spontaneous
## gender: female
##                   vars   n   mean     sd median trimmed    mad    min    max
## filename*            1 113  57.00  32.76  57.00   57.00  41.51   1.00 113.00
## subject              2 113 275.07 154.03 251.00  271.66 185.32  20.00 534.00
## gender*              3 113   1.00   0.00   1.00    1.00   0.00   1.00   1.00
## age                  4 113  11.01   2.45  10.00   10.75   2.97   8.00  17.00
## smile_type*          5 113   1.00   0.00   1.00    1.00   0.00   1.00   1.00
## frame_min            6 113   1.00   0.00   1.00    1.00   0.00   1.00   1.00
## timestamp_min        7 113   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## gaze_angle_x_min     8 113   0.15   0.07   0.16    0.16   0.06  -0.13   0.28
## gaze_angle_y_min     9 113   0.20   0.08   0.20    0.20   0.08  -0.07   0.48
## pose_Rx_min         10 113   0.10   0.11   0.12    0.11   0.08  -0.37   0.31
## pose_Ry_min         11 113  -0.20   0.07  -0.20   -0.20   0.06  -0.38   0.04
## pose_Rz_min         12 113  -0.05   0.09  -0.04   -0.04   0.08  -0.34   0.12
## AU01_r_min          13 113   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU02_r_min          14 113   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU04_r_min          15 113   0.14   0.53   0.00    0.01   0.00   0.00   3.36
## AU05_r_min          16 113   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU06_r_min          17 113   0.07   0.18   0.00    0.02   0.00   0.00   0.93
## AU07_r_min          18 113   0.28   0.56   0.00    0.15   0.00   0.00   3.59
## AU09_r_min          19 113   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU10_r_min          20 113   0.03   0.12   0.00    0.00   0.00   0.00   0.86
## AU12_r_min          21 113   0.44   0.49   0.28    0.37   0.42   0.00   1.76
## AU14_r_min          22 113   0.64   0.46   0.59    0.62   0.52   0.00   1.59
## AU15_r_min          23 113   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU17_r_min          24 113   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU20_r_min          25 113   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU23_r_min          26 113   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU25_r_min          27 113   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU26_r_min          28 113   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU45_r_min          29 113   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## lip_min             30 113 151.98  18.28 151.90  152.23  17.85 101.23 189.97
## eye_min             31 113   5.72   3.43   4.70    5.51   3.93   0.84  13.82
## amplitude_min       32 113   0.38   0.12   0.38    0.38   0.12   0.04   0.63
## stage_min           33 113   0.03   0.01   0.03    0.03   0.01   0.02   0.09
## apex_min            34 113   0.55   0.14   0.55    0.55   0.15   0.16   0.80
## offset_min          35 113   0.42   0.13   0.43    0.43   0.13   0.12   0.65
## onset_min           36 113   0.40   0.12   0.40    0.40   0.12   0.04   0.68
## frame_max           37 113 237.58 100.18 212.00  226.31  71.16  77.00 606.00
## timestamp_max       38 113   4.73   2.00   4.22    4.51   1.42   1.52  12.10
## gaze_angle_x_max    39 113   0.25   0.06   0.25    0.25   0.06   0.11   0.38
## gaze_angle_y_max    40 113   0.42   0.10   0.42    0.42   0.12   0.14   0.62
## pose_Rx_max         41 113   0.23   0.08   0.22    0.23   0.08   0.00   0.42
## pose_Ry_max         42 113  -0.12   0.08  -0.13   -0.12   0.08  -0.30   0.08
## pose_Rz_max         43 113   0.06   0.08   0.05    0.05   0.07  -0.10   0.30
## AU01_r_max          44 113   0.70   0.39   0.61    0.65   0.30   0.15   2.30
## AU02_r_max          45 113   0.58   0.39   0.44    0.50   0.24   0.17   2.24
## AU04_r_max          46 113   0.66   0.86   0.40    0.49   0.59   0.00   4.49
## AU05_r_max          47 113   0.52   0.29   0.46    0.48   0.24   0.12   2.01
## AU06_r_max          48 113   2.10   0.70   2.03    2.08   0.70   0.44   3.64
## AU07_r_max          49 113   2.05   0.94   2.04    2.04   0.86   0.00   5.00
## AU09_r_max          50 113   0.38   0.25   0.30    0.34   0.15   0.08   1.88
## AU10_r_max          51 113   1.55   0.74   1.61    1.53   0.76   0.00   3.34
## AU12_r_max          52 113   2.89   0.56   2.96    2.92   0.59   1.19   4.20
## AU14_r_max          53 113   1.91   0.39   1.91    1.91   0.43   1.03   2.91
## AU15_r_max          54 113   0.46   0.24   0.42    0.43   0.21   0.14   1.77
## AU17_r_max          55 113   1.39   0.64   1.35    1.33   0.44   0.30   3.96
## AU20_r_max          56 113   0.52   0.28   0.44    0.48   0.24   0.15   1.61
## AU23_r_max          57 113   0.64   0.38   0.58    0.59   0.37   0.11   1.91
## AU25_r_max          58 113   1.31   0.71   1.15    1.24   0.65   0.32   3.12
## AU26_r_max          59 113   1.16   0.51   1.09    1.10   0.39   0.31   3.27
## AU45_r_max          60 113   1.64   1.07   1.53    1.58   1.44   0.22   4.27
## lip_max             61 113 190.36  21.24 190.20  191.59  19.92 127.31 228.96
## eye_max             62 113  12.63   2.22  12.75   12.65   2.07   7.46  18.17
## amplitude_max       63 113   0.64   0.14   0.64    0.64   0.13   0.22   0.89
## stage_max           64 113   0.06   0.05   0.05    0.06   0.02   0.03   0.48
## apex_max            65 113   0.64   0.14   0.64    0.64   0.13   0.22   0.89
## offset_max          66 113   0.54   0.14   0.55    0.55   0.15   0.15   0.80
## onset_max           67 113   0.54   0.13   0.55    0.55   0.14   0.16   0.79
## frame_mean          68 113 119.29  50.09 106.50  113.65  35.58  39.00 303.50
## timestamp_mean      69 113   2.37   1.00   2.11    2.25   0.71   0.76   6.05
## gaze_angle_x_mean   70 113   0.20   0.06   0.20    0.20   0.05   0.07   0.32
## gaze_angle_y_mean   71 113   0.29   0.07   0.28    0.28   0.06   0.12   0.50
## pose_Rx_mean        72 113   0.17   0.08   0.17    0.18   0.07  -0.02   0.37
## pose_Ry_mean        73 113  -0.16   0.07  -0.17   -0.16   0.06  -0.35   0.05
## pose_Rz_mean        74 113   0.01   0.07   0.00    0.00   0.07  -0.16   0.16
## AU01_r_mean         75 113   0.11   0.06   0.10    0.10   0.05   0.03   0.36
## AU02_r_mean         76 113   0.05   0.04   0.04    0.05   0.02   0.02   0.29
## AU04_r_mean         77 113   0.31   0.65   0.03    0.16   0.04   0.00   3.75
## AU05_r_mean         78 113   0.04   0.02   0.03    0.04   0.01   0.01   0.12
## AU06_r_mean         79 113   1.24   0.56   1.22    1.22   0.63   0.10   2.89
## AU07_r_mean         80 113   1.18   0.83   1.15    1.12   0.88   0.00   4.76
## AU09_r_mean         81 113   0.05   0.04   0.03    0.04   0.01   0.01   0.29
## AU10_r_mean         82 113   0.84   0.52   0.88    0.83   0.62   0.00   2.13
## AU12_r_mean         83 113   2.05   0.55   2.05    2.07   0.55   0.41   3.40
## AU14_r_mean         84 113   1.36   0.37   1.37    1.37   0.43   0.53   2.21
## AU15_r_mean         85 113   0.08   0.04   0.06    0.07   0.03   0.03   0.23
## AU17_r_mean         86 113   0.39   0.21   0.35    0.37   0.18   0.11   1.06
## AU20_r_mean         87 113   0.07   0.04   0.06    0.06   0.03   0.02   0.32
## AU23_r_mean         88 113   0.08   0.05   0.07    0.07   0.04   0.02   0.32
## AU25_r_mean         89 113   0.48   0.33   0.39    0.44   0.30   0.08   1.63
## AU26_r_mean         90 113   0.30   0.15   0.26    0.28   0.12   0.09   0.80
## AU45_r_mean         91 113   0.17   0.12   0.13    0.15   0.09   0.04   0.63
## lip_mean            92 113 176.97  20.27 177.87  177.92  21.92 118.36 214.74
## eye_mean            93 113  10.20   2.11  10.31   10.24   2.02   5.32  15.40
## amplitude_mean      94 113   0.55   0.14   0.55    0.55   0.15   0.16   0.80
## stage_mean          95 113   0.04   0.02   0.04    0.04   0.01   0.03   0.13
## apex_mean           96 113   0.60   0.14   0.60    0.61   0.14   0.18   0.87
## offset_mean         97 113   0.48   0.13   0.48    0.48   0.14   0.14   0.73
## onset_mean          98 113   0.46   0.13   0.46    0.46   0.14   0.08   0.72
## frame_sd            99 113  68.73  28.92  61.34   65.47  20.54  22.37 175.08
## timestamp_sd       100 113   1.37   0.58   1.23    1.31   0.41   0.45   3.50
## gaze_angle_x_sd    101 113   0.02   0.01   0.02    0.02   0.01   0.01   0.10
## gaze_angle_y_sd    102 113   0.04   0.02   0.04    0.04   0.02   0.01   0.10
## pose_Rx_sd         103 113   0.03   0.02   0.02    0.03   0.01   0.01   0.16
## pose_Ry_sd         104 113   0.02   0.01   0.01    0.02   0.01   0.00   0.09
## pose_Rz_sd         105 113   0.03   0.03   0.02    0.02   0.01   0.00   0.17
## AU01_r_sd          106 113   0.17   0.10   0.15    0.15   0.08   0.04   0.57
## AU02_r_sd          107 113   0.12   0.09   0.09    0.10   0.05   0.03   0.62
## AU04_r_sd          108 113   0.12   0.15   0.07    0.10   0.11   0.00   0.66
## AU05_r_sd          109 113   0.10   0.06   0.08    0.09   0.03   0.03   0.35
## AU06_r_sd          110 113   0.60   0.21   0.56    0.59   0.19   0.13   1.15
## AU07_r_sd          111 113   0.44   0.23   0.42    0.42   0.17   0.00   1.26
## AU09_r_sd          112 113   0.09   0.07   0.07    0.08   0.03   0.02   0.56
## AU10_r_sd          113 113   0.45   0.23   0.44    0.45   0.22   0.00   1.15
## AU12_r_sd          114 113   0.71   0.19   0.69    0.70   0.21   0.33   1.14
## AU14_r_sd          115 113   0.29   0.11   0.27    0.28   0.12   0.07   0.64
## AU15_r_sd          116 113   0.11   0.06   0.09    0.10   0.04   0.04   0.43
## AU17_r_sd          117 113   0.39   0.21   0.35    0.36   0.16   0.08   1.23
## AU20_r_sd          118 113   0.12   0.08   0.10    0.11   0.05   0.03   0.52
## AU23_r_sd          119 113   0.15   0.09   0.13    0.14   0.09   0.03   0.54
## AU25_r_sd          120 113   0.44   0.28   0.39    0.41   0.28   0.07   1.22
## AU26_r_sd          121 113   0.32   0.16   0.30    0.31   0.14   0.07   0.94
## AU45_r_sd          122 113   0.33   0.24   0.27    0.30   0.23   0.05   1.21
## lip_sd             123 113  10.86   3.41  10.53   10.75   3.43   3.98  18.73
## eye_sd             124 113   1.43   0.72   1.27    1.37   0.69   0.23   3.77
## amplitude_sd       125 113   0.07   0.02   0.07    0.07   0.02   0.03   0.12
## stage_sd           126 113   0.01   0.01   0.01    0.01   0.00   0.00   0.10
## apex_sd            127 113   0.02   0.01   0.02    0.02   0.01   0.01   0.05
## offset_sd          128 113   0.04   0.02   0.03    0.03   0.02   0.00   0.14
## onset_sd           129 113   0.05   0.02   0.04    0.04   0.02   0.01   0.12
##                    range  skew kurtosis    se
## filename*         112.00  0.00    -1.23  3.08
## subject           514.00  0.26    -1.23 14.49
## gender*             0.00   NaN      NaN  0.00
## age                 9.00  0.79    -0.11  0.23
## smile_type*         0.00   NaN      NaN  0.00
## frame_min           0.00   NaN      NaN  0.00
## timestamp_min       0.00   NaN      NaN  0.00
## gaze_angle_x_min    0.41 -0.83     1.27  0.01
## gaze_angle_y_min    0.56  0.46     1.76  0.01
## pose_Rx_min         0.68 -0.96     2.32  0.01
## pose_Ry_min         0.41  0.32     0.30  0.01
## pose_Rz_min         0.46 -0.78     1.21  0.01
## AU01_r_min          0.00   NaN      NaN  0.00
## AU02_r_min          0.00   NaN      NaN  0.00
## AU04_r_min          3.36  4.45    20.10  0.05
## AU05_r_min          0.00   NaN      NaN  0.00
## AU06_r_min          0.93  2.72     7.09  0.02
## AU07_r_min          3.59  3.20    12.95  0.05
## AU09_r_min          0.00   NaN      NaN  0.00
## AU10_r_min          0.86  4.26    20.70  0.01
## AU12_r_min          1.76  0.89    -0.38  0.05
## AU14_r_min          1.59  0.29    -1.04  0.04
## AU15_r_min          0.00   NaN      NaN  0.00
## AU17_r_min          0.00   NaN      NaN  0.00
## AU20_r_min          0.00   NaN      NaN  0.00
## AU23_r_min          0.00   NaN      NaN  0.00
## AU25_r_min          0.00   NaN      NaN  0.00
## AU26_r_min          0.00   NaN      NaN  0.00
## AU45_r_min          0.00   NaN      NaN  0.00
## lip_min            88.74 -0.16    -0.14  1.72
## eye_min            12.98  0.46    -1.04  0.32
## amplitude_min       0.59 -0.16    -0.14  0.01
## stage_min           0.07  3.04    11.51  0.00
## apex_min            0.65 -0.49     0.07  0.01
## offset_min          0.52 -0.27    -0.51  0.01
## onset_min           0.64 -0.19    -0.02  0.01
## frame_max         529.00  1.18     1.41  9.42
## timestamp_max      10.58  1.18     1.41  0.19
## gaze_angle_x_max    0.28 -0.40    -0.29  0.01
## gaze_angle_y_max    0.48 -0.09    -0.73  0.01
## pose_Rx_max         0.42 -0.37     0.30  0.01
## pose_Ry_max         0.38  0.14    -0.41  0.01
## pose_Rz_max         0.41  0.61     0.48  0.01
## AU01_r_max          2.15  1.27     1.93  0.04
## AU02_r_max          2.07  2.15     5.20  0.04
## AU04_r_max          4.49  2.07     4.93  0.08
## AU05_r_max          1.89  1.88     5.46  0.03
## AU06_r_max          3.20  0.24    -0.56  0.07
## AU07_r_max          5.00  0.32     0.60  0.09
## AU09_r_max          1.80  2.62    10.75  0.02
## AU10_r_max          3.34  0.12    -0.32  0.07
## AU12_r_max          3.01 -0.43     0.13  0.05
## AU14_r_max          1.88  0.00    -0.76  0.04
## AU15_r_max          1.63  2.10     7.59  0.02
## AU17_r_max          3.66  1.33     2.99  0.06
## AU20_r_max          1.46  1.36     2.10  0.03
## AU23_r_max          1.80  1.13     1.12  0.04
## AU25_r_max          2.80  0.78    -0.18  0.07
## AU26_r_max          2.96  1.32     2.77  0.05
## AU45_r_max          4.05  0.34    -1.16  0.10
## lip_max           101.65 -0.60     0.35  2.00
## eye_max            10.71 -0.08    -0.04  0.21
## amplitude_max       0.68 -0.60     0.35  0.01
## stage_max           0.45  6.08    46.18  0.00
## apex_max            0.68 -0.60     0.35  0.01
## offset_max          0.64 -0.47     0.04  0.01
## onset_max           0.64 -0.49     0.06  0.01
## frame_mean        264.50  1.18     1.41  4.71
## timestamp_mean      5.29  1.18     1.41  0.09
## gaze_angle_x_mean   0.26 -0.27    -0.21  0.01
## gaze_angle_y_mean   0.39  0.61     0.79  0.01
## pose_Rx_mean        0.39 -0.11    -0.18  0.01
## pose_Ry_mean        0.40  0.15     0.17  0.01
## pose_Rz_mean        0.32  0.10    -0.54  0.01
## AU01_r_mean         0.32  1.38     2.10  0.01
## AU02_r_mean         0.27  3.22    14.34  0.00
## AU04_r_mean         3.75  3.27    11.58  0.06
## AU05_r_mean         0.10  1.49     2.43  0.00
## AU06_r_mean         2.80  0.50     0.02  0.05
## AU07_r_mean         4.76  1.03     2.33  0.08
## AU09_r_mean         0.28  3.48    17.03  0.00
## AU10_r_mean         2.13  0.23    -0.75  0.05
## AU12_r_mean         2.98 -0.24    -0.04  0.05
## AU14_r_mean         1.68 -0.10    -0.90  0.04
## AU15_r_mean         0.20  1.62     2.73  0.00
## AU17_r_mean         0.94  1.07     0.90  0.02
## AU20_r_mean         0.29  2.65     9.82  0.00
## AU23_r_mean         0.30  1.79     4.18  0.00
## AU25_r_mean         1.55  1.13     0.91  0.03
## AU26_r_mean         0.71  1.25     1.56  0.01
## AU45_r_mean         0.59  1.60     2.45  0.01
## lip_mean           96.38 -0.49     0.05  1.91
## eye_mean           10.08 -0.12    -0.18  0.20
## amplitude_mean      0.64 -0.49     0.05  0.01
## stage_mean          0.11  3.25    12.67  0.00
## apex_mean           0.68 -0.57     0.24  0.01
## offset_mean         0.59 -0.29    -0.36  0.01
## onset_mean          0.64 -0.33     0.08  0.01
## frame_sd          152.71  1.18     1.41  2.72
## timestamp_sd        3.05  1.18     1.41  0.05
## gaze_angle_x_sd     0.09  2.94    14.68  0.00
## gaze_angle_y_sd     0.09  0.75     0.52  0.00
## pose_Rx_sd          0.15  2.52     7.95  0.00
## pose_Ry_sd          0.09  2.23     6.53  0.00
## pose_Rz_sd          0.16  2.52     7.85  0.00
## AU01_r_sd           0.53  1.27     1.70  0.01
## AU02_r_sd           0.59  2.88    10.91  0.01
## AU04_r_sd           0.66  1.56     2.43  0.01
## AU05_r_sd           0.32  1.80     3.81  0.01
## AU06_r_sd           1.03  0.52    -0.22  0.02
## AU07_r_sd           1.26  0.93     1.53  0.02
## AU09_r_sd           0.54  3.32    16.13  0.01
## AU10_r_sd           1.15  0.37     0.24  0.02
## AU12_r_sd           0.80  0.28    -0.62  0.02
## AU14_r_sd           0.57  0.71     0.07  0.01
## AU15_r_sd           0.39  1.98     5.75  0.01
## AU17_r_sd           1.14  1.42     2.61  0.02
## AU20_r_sd           0.49  2.19     6.86  0.01
## AU23_r_sd           0.51  1.39     2.27  0.01
## AU25_r_sd           1.15  0.85    -0.19  0.03
## AU26_r_sd           0.87  1.30     2.18  0.02
## AU45_r_sd           1.16  1.14     1.20  0.02
## lip_sd             14.75  0.27    -0.63  0.32
## eye_sd              3.54  0.89     0.77  0.07
## amplitude_sd        0.10  0.27    -0.63  0.00
## stage_sd            0.09  6.61    53.38  0.00
## apex_sd             0.05  0.89     0.65  0.00
## offset_sd           0.13  1.49     2.81  0.00
## onset_sd            0.11  0.90     0.83  0.00
## ------------------------------------------------------------ 
## smile_type: deliberate 
## gender: male  
##                   vars   n   mean     sd median trimmed    mad    min    max
## filename*            1 124  62.50  35.94  62.50   62.50  45.96   1.00 124.00
## subject              2 124 297.57 151.14 282.50  300.13 220.17  54.00 520.00
## gender*              3 124   1.00   0.00   1.00    1.00   0.00   1.00   1.00
## age                  4 124  10.49   2.11  10.00   10.21   1.48   8.00  17.00
## smile_type*          5 124   1.00   0.00   1.00    1.00   0.00   1.00   1.00
## frame_min            6 124   1.00   0.00   1.00    1.00   0.00   1.00   1.00
## timestamp_min        7 124   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## gaze_angle_x_min     8 124   0.15   0.09   0.16    0.15   0.07  -0.12   0.37
## gaze_angle_y_min     9 124   0.20   0.09   0.22    0.21   0.08  -0.10   0.38
## pose_Rx_min         10 124   0.10   0.11   0.11    0.11   0.10  -0.33   0.29
## pose_Ry_min         11 124  -0.20   0.09  -0.20   -0.20   0.07  -0.44   0.01
## pose_Rz_min         12 124  -0.04   0.07  -0.03   -0.04   0.07  -0.26   0.09
## AU01_r_min          13 124   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU02_r_min          14 124   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU04_r_min          15 124   0.12   0.40   0.00    0.01   0.00   0.00   2.18
## AU05_r_min          16 124   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU06_r_min          17 124   0.04   0.20   0.00    0.00   0.00   0.00   1.21
## AU07_r_min          18 124   0.12   0.40   0.00    0.01   0.00   0.00   2.36
## AU09_r_min          19 124   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU10_r_min          20 124   0.00   0.02   0.00    0.00   0.00   0.00   0.24
## AU12_r_min          21 124   0.09   0.24   0.00    0.03   0.00   0.00   1.34
## AU14_r_min          22 124   0.46   0.47   0.34    0.40   0.50   0.00   1.82
## AU15_r_min          23 124   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU17_r_min          24 124   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU20_r_min          25 124   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU23_r_min          26 124   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU25_r_min          27 124   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU26_r_min          28 124   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU45_r_min          29 124   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## lip_min             30 124 145.32  17.01 147.00  145.34  16.40 110.17 184.45
## eye_min             31 124   5.77   3.96   4.56    5.43   3.85   0.57  15.49
## amplitude_min       32 124   0.34   0.11   0.35    0.34   0.11   0.10   0.60
## stage_min           33 124   0.03   0.01   0.03    0.03   0.01   0.02   0.06
## apex_min            34 124   0.54   0.13   0.54    0.54   0.14   0.27   0.83
## offset_min          35 124   0.36   0.12   0.38    0.36   0.12   0.12   0.61
## onset_min           36 124   0.36   0.12   0.36    0.36   0.11   0.10   0.73
## frame_max           37 124 163.86  53.03 153.00  157.38  40.03  90.00 385.00
## timestamp_max       38 124   3.26   1.06   3.04    3.13   0.80   1.78   7.68
## gaze_angle_x_max    39 124   0.24   0.08   0.24    0.24   0.07   0.02   0.46
## gaze_angle_y_max    40 124   0.41   0.11   0.40    0.40   0.11   0.10   0.69
## pose_Rx_max         41 124   0.19   0.10   0.21    0.20   0.09  -0.10   0.36
## pose_Ry_max         42 124  -0.14   0.08  -0.14   -0.14   0.08  -0.38   0.04
## pose_Rz_max         43 124   0.03   0.08   0.03    0.02   0.06  -0.16   0.28
## AU01_r_max          44 124   0.84   0.72   0.72    0.71   0.42   0.13   5.00
## AU02_r_max          45 124   0.56   0.39   0.47    0.48   0.19   0.15   3.09
## AU04_r_max          46 124   0.46   0.71   0.00    0.31   0.01   0.00   2.83
## AU05_r_max          47 124   0.53   0.36   0.46    0.48   0.26   0.12   2.30
## AU06_r_max          48 124   1.50   0.77   1.50    1.50   0.72   0.00   3.53
## AU07_r_max          49 124   1.50   0.91   1.46    1.45   0.76   0.00   4.40
## AU09_r_max          50 124   0.32   0.19   0.26    0.29   0.13   0.10   0.98
## AU10_r_max          51 124   0.81   0.67   0.69    0.77   1.02   0.00   2.28
## AU12_r_max          52 124   2.66   0.72   2.70    2.65   0.74   0.79   4.70
## AU14_r_max          53 124   1.85   0.46   1.86    1.86   0.51   0.83   2.89
## AU15_r_max          54 124   0.42   0.23   0.36    0.38   0.17   0.13   1.27
## AU17_r_max          55 124   1.17   0.63   1.10    1.10   0.61   0.29   3.97
## AU20_r_max          56 124   0.42   0.23   0.36    0.39   0.20   0.10   1.46
## AU23_r_max          57 124   0.52   0.34   0.46    0.47   0.27   0.11   1.61
## AU25_r_max          58 124   1.32   0.76   1.13    1.26   0.73   0.32   3.30
## AU26_r_max          59 124   1.09   0.48   1.00    1.04   0.39   0.38   2.93
## AU45_r_max          60 124   1.93   1.34   1.98    1.85   1.93   0.22   5.00
## lip_max             61 124 189.14  20.68 191.42  188.83  22.46 144.05 239.26
## eye_max             62 124  12.98   2.26  12.92   12.95   2.01   7.83  19.03
## amplitude_max       63 124   0.63   0.14   0.64    0.63   0.15   0.33   0.96
## stage_max           64 124   0.07   0.03   0.06    0.06   0.02   0.03   0.20
## apex_max            65 124   0.63   0.14   0.64    0.63   0.15   0.33   0.96
## offset_max          66 124   0.52   0.13   0.53    0.52   0.13   0.26   0.82
## onset_max           67 124   0.52   0.12   0.53    0.53   0.13   0.26   0.81
## frame_mean          68 124  82.43  26.52  77.00   79.19  20.02  45.50 193.00
## timestamp_mean      69 124   1.63   0.53   1.52    1.56   0.40   0.89   3.84
## gaze_angle_x_mean   70 124   0.19   0.08   0.21    0.20   0.06  -0.04   0.41
## gaze_angle_y_mean   71 124   0.28   0.08   0.30    0.29   0.07   0.05   0.46
## pose_Rx_mean        72 124   0.15   0.10   0.17    0.16   0.10  -0.11   0.32
## pose_Ry_mean        73 124  -0.17   0.08  -0.17   -0.17   0.07  -0.41   0.04
## pose_Rz_mean        74 124  -0.01   0.07   0.00   -0.01   0.06  -0.18   0.16
## AU01_r_mean         75 124   0.15   0.16   0.11    0.12   0.06   0.03   1.06
## AU02_r_mean         76 124   0.06   0.05   0.05    0.05   0.02   0.02   0.37
## AU04_r_mean         77 124   0.24   0.52   0.00    0.10   0.00   0.00   2.40
## AU05_r_mean         78 124   0.05   0.03   0.04    0.04   0.02   0.01   0.24
## AU06_r_mean         79 124   0.80   0.53   0.71    0.77   0.53   0.00   2.48
## AU07_r_mean         80 124   0.78   0.68   0.66    0.68   0.58   0.00   3.02
## AU09_r_mean         81 124   0.04   0.02   0.03    0.04   0.02   0.01   0.15
## AU10_r_mean         82 124   0.36   0.36   0.25    0.31   0.37   0.00   1.46
## AU12_r_mean         83 124   1.73   0.56   1.84    1.74   0.55   0.31   3.25
## AU14_r_mean         84 124   1.31   0.44   1.36    1.33   0.44   0.31   2.20
## AU15_r_mean         85 124   0.07   0.04   0.06    0.07   0.02   0.03   0.36
## AU17_r_mean         86 124   0.35   0.19   0.31    0.33   0.19   0.08   1.02
## AU20_r_mean         87 124   0.06   0.03   0.05    0.05   0.02   0.02   0.18
## AU23_r_mean         88 124   0.07   0.05   0.06    0.06   0.04   0.02   0.29
## AU25_r_mean         89 124   0.55   0.42   0.42    0.50   0.35   0.07   1.86
## AU26_r_mean         90 124   0.29   0.13   0.28    0.27   0.12   0.09   0.78
## AU45_r_mean         91 124   0.20   0.14   0.16    0.18   0.13   0.04   0.79
## lip_mean            92 124 174.86  18.90 175.85  174.96  20.62 134.86 219.12
## eye_mean            93 124  10.71   2.21  10.52   10.60   1.68   6.06  16.57
## amplitude_mean      94 124   0.53   0.13   0.54    0.53   0.14   0.27   0.83
## stage_mean          95 124   0.04   0.01   0.04    0.04   0.01   0.02   0.09
## apex_mean           96 124   0.60   0.14   0.61    0.60   0.14   0.31   0.89
## offset_mean         97 124   0.42   0.12   0.43    0.42   0.13   0.18   0.72
## onset_mean          98 124   0.42   0.12   0.43    0.42   0.12   0.12   0.75
## frame_sd            99 124  47.45  15.31  44.31   45.58  11.56  26.12 111.28
## timestamp_sd       100 124   0.95   0.31   0.89    0.91   0.23   0.52   2.23
## gaze_angle_x_sd    101 124   0.02   0.01   0.02    0.02   0.01   0.00   0.09
## gaze_angle_y_sd    102 124   0.04   0.02   0.04    0.04   0.02   0.01   0.12
## pose_Rx_sd         103 124   0.02   0.01   0.02    0.02   0.01   0.01   0.08
## pose_Ry_sd         104 124   0.01   0.01   0.01    0.01   0.01   0.00   0.06
## pose_Rz_sd         105 124   0.02   0.02   0.01    0.02   0.01   0.00   0.11
## AU01_r_sd          106 124   0.23   0.25   0.17    0.18   0.10   0.04   1.78
## AU02_r_sd          107 124   0.12   0.11   0.10    0.10   0.04   0.03   0.80
## AU04_r_sd          108 124   0.08   0.12   0.00    0.06   0.00   0.00   0.47
## AU05_r_sd          109 124   0.11   0.08   0.09    0.10   0.05   0.03   0.53
## AU06_r_sd          110 124   0.53   0.29   0.52    0.52   0.25   0.00   1.21
## AU07_r_sd          111 124   0.39   0.25   0.37    0.38   0.24   0.00   1.15
## AU09_r_sd          112 124   0.08   0.05   0.06    0.07   0.03   0.02   0.25
## AU10_r_sd          113 124   0.28   0.25   0.22    0.25   0.33   0.00   0.97
## AU12_r_sd          114 124   0.92   0.30   0.91    0.91   0.29   0.24   2.05
## AU14_r_sd          115 124   0.36   0.14   0.36    0.35   0.15   0.12   0.82
## AU15_r_sd          116 124   0.11   0.07   0.09    0.10   0.04   0.03   0.46
## AU17_r_sd          117 124   0.36   0.22   0.33    0.33   0.22   0.07   1.11
## AU20_r_sd          118 124   0.10   0.06   0.09    0.09   0.04   0.02   0.34
## AU23_r_sd          119 124   0.13   0.09   0.11    0.12   0.08   0.03   0.51
## AU25_r_sd          120 124   0.47   0.33   0.37    0.44   0.29   0.07   1.42
## AU26_r_sd          121 124   0.32   0.15   0.29    0.30   0.13   0.09   0.79
## AU45_r_sd          122 124   0.42   0.31   0.38    0.39   0.35   0.05   1.44
## lip_sd             123 124  14.20   4.84  13.58   13.93   4.17   2.84  31.30
## eye_sd             124 124   1.54   0.91   1.45    1.47   0.98   0.19   5.10
## amplitude_sd       125 124   0.09   0.03   0.09    0.09   0.03   0.02   0.21
## stage_sd           126 124   0.01   0.01   0.01    0.01   0.00   0.00   0.05
## apex_sd            127 124   0.02   0.01   0.02    0.02   0.01   0.01   0.07
## offset_sd          128 124   0.05   0.02   0.04    0.04   0.02   0.00   0.13
## onset_sd           129 124   0.06   0.03   0.05    0.05   0.02   0.00   0.15
##                    range  skew kurtosis    se
## filename*         123.00  0.00    -1.23  3.23
## subject           466.00 -0.04    -1.52 13.57
## gender*             0.00   NaN      NaN  0.00
## age                 9.00  1.11     0.89  0.19
## smile_type*         0.00   NaN      NaN  0.00
## frame_min           0.00   NaN      NaN  0.00
## timestamp_min       0.00   NaN      NaN  0.00
## gaze_angle_x_min    0.49 -0.59     1.22  0.01
## gaze_angle_y_min    0.48 -0.50     0.10  0.01
## pose_Rx_min         0.62 -0.88     0.85  0.01
## pose_Ry_min         0.45  0.01     0.26  0.01
## pose_Rz_min         0.35 -0.64    -0.01  0.01
## AU01_r_min          0.00   NaN      NaN  0.00
## AU02_r_min          0.00   NaN      NaN  0.00
## AU04_r_min          2.18  3.45    11.17  0.04
## AU05_r_min          0.00   NaN      NaN  0.00
## AU06_r_min          1.21  4.77    22.63  0.02
## AU07_r_min          2.36  4.01    16.74  0.04
## AU09_r_min          0.00   NaN      NaN  0.00
## AU10_r_min          0.24  8.50    74.37  0.00
## AU12_r_min          1.34  3.12    10.00  0.02
## AU14_r_min          1.82  0.85    -0.20  0.04
## AU15_r_min          0.00   NaN      NaN  0.00
## AU17_r_min          0.00   NaN      NaN  0.00
## AU20_r_min          0.00   NaN      NaN  0.00
## AU23_r_min          0.00   NaN      NaN  0.00
## AU25_r_min          0.00   NaN      NaN  0.00
## AU26_r_min          0.00   NaN      NaN  0.00
## AU45_r_min          0.00   NaN      NaN  0.00
## lip_min            74.28 -0.02    -0.47  1.53
## eye_min            14.91  0.64    -0.71  0.36
## amplitude_min       0.50 -0.02    -0.47  0.01
## stage_min           0.04  1.06     0.99  0.00
## apex_min            0.56 -0.06    -0.59  0.01
## offset_min          0.50 -0.12    -0.69  0.01
## onset_min           0.63  0.10    -0.07  0.01
## frame_max         295.00  1.45     2.64  4.76
## timestamp_max       5.90  1.45     2.64  0.10
## gaze_angle_x_max    0.44 -0.23     0.42  0.01
## gaze_angle_y_max    0.59  0.16    -0.09  0.01
## pose_Rx_max         0.46 -0.67    -0.26  0.01
## pose_Ry_max         0.43 -0.02     0.21  0.01
## pose_Rz_max         0.44  0.74     1.44  0.01
## AU01_r_max          4.87  2.99    11.42  0.06
## AU02_r_max          2.94  3.26    14.86  0.04
## AU04_r_max          2.83  1.60     1.69  0.06
## AU05_r_max          2.18  2.20     6.49  0.03
## AU06_r_max          3.53  0.15    -0.34  0.07
## AU07_r_max          4.40  0.49     0.22  0.08
## AU09_r_max          0.88  1.39     1.53  0.02
## AU10_r_max          2.28  0.27    -1.25  0.06
## AU12_r_max          3.91  0.04     0.18  0.06
## AU14_r_max          2.06 -0.09    -0.57  0.04
## AU15_r_max          1.14  1.59     2.34  0.02
## AU17_r_max          3.68  1.38     2.96  0.06
## AU20_r_max          1.36  1.57     3.24  0.02
## AU23_r_max          1.50  1.33     1.49  0.03
## AU25_r_max          2.98  0.64    -0.68  0.07
## AU26_r_max          2.55  1.10     1.22  0.04
## AU45_r_max          4.78  0.30    -1.18  0.12
## lip_max            95.21  0.08    -0.39  1.86
## eye_max            11.19  0.16    -0.03  0.20
## amplitude_max       0.64  0.08    -0.39  0.01
## stage_max           0.16  1.70     2.75  0.00
## apex_max            0.64  0.08    -0.39  0.01
## offset_max          0.56  0.00    -0.57  0.01
## onset_max           0.55 -0.07    -0.63  0.01
## frame_mean        147.50  1.45     2.64  2.38
## timestamp_mean      2.95  1.45     2.64  0.05
## gaze_angle_x_mean   0.45 -0.36     0.85  0.01
## gaze_angle_y_mean   0.41 -0.51    -0.06  0.01
## pose_Rx_mean        0.43 -0.71    -0.37  0.01
## pose_Ry_mean        0.44  0.03     0.32  0.01
## pose_Rz_mean        0.34 -0.05     0.00  0.01
## AU01_r_mean         1.03  3.91    16.81  0.01
## AU02_r_mean         0.36  4.13    20.44  0.00
## AU04_r_mean         2.40  2.64     6.40  0.05
## AU05_r_mean         0.23  2.68    10.76  0.00
## AU06_r_mean         2.48  0.62     0.24  0.05
## AU07_r_mean         3.02  1.22     1.49  0.06
## AU09_r_mean         0.14  1.58     3.19  0.00
## AU10_r_mean         1.46  0.79    -0.28  0.03
## AU12_r_mean         2.94 -0.16    -0.28  0.05
## AU14_r_mean         1.89 -0.23    -0.76  0.04
## AU15_r_mean         0.34  3.14    15.26  0.00
## AU17_r_mean         0.94  0.89     0.54  0.02
## AU20_r_mean         0.16  1.79     3.53  0.00
## AU23_r_mean         0.27  1.72     3.16  0.00
## AU25_r_mean         1.79  1.02     0.30  0.04
## AU26_r_mean         0.69  1.23     1.71  0.01
## AU45_r_mean         0.75  1.33     2.54  0.01
## lip_mean           84.25 -0.05    -0.58  1.70
## eye_mean           10.51  0.46     0.11  0.20
## amplitude_mean      0.56 -0.05    -0.58  0.01
## stage_mean          0.06  1.25     1.19  0.00
## apex_mean           0.59  0.05    -0.53  0.01
## offset_mean         0.54 -0.05    -0.67  0.01
## onset_mean          0.62 -0.06    -0.27  0.01
## frame_sd           85.16  1.45     2.64  1.37
## timestamp_sd        1.70  1.45     2.64  0.03
## gaze_angle_x_sd     0.09  2.87    11.79  0.00
## gaze_angle_y_sd     0.11  1.18     2.12  0.00
## pose_Rx_sd          0.08  1.78     3.79  0.00
## pose_Ry_sd          0.06  2.67     9.23  0.00
## pose_Rz_sd          0.11  2.21     5.01  0.00
## AU01_r_sd           1.74  3.75    16.21  0.02
## AU02_r_sd           0.77  3.78    17.96  0.01
## AU04_r_sd           0.47  1.29     0.57  0.01
## AU05_r_sd           0.51  2.32     7.43  0.01
## AU06_r_sd           1.21  0.19    -0.39  0.03
## AU07_r_sd           1.15  0.40    -0.09  0.02
## AU09_r_sd           0.23  1.33     1.27  0.00
## AU10_r_sd           0.97  0.60    -0.57  0.02
## AU12_r_sd           1.81  0.59     1.42  0.03
## AU14_r_sd           0.70  0.46    -0.12  0.01
## AU15_r_sd           0.43  2.17     6.17  0.01
## AU17_r_sd           1.04  1.11     1.27  0.02
## AU20_r_sd           0.31  1.74     3.45  0.01
## AU23_r_sd           0.49  1.54     2.47  0.01
## AU25_r_sd           1.35  0.81    -0.33  0.03
## AU26_r_sd           0.70  1.00     0.75  0.01
## AU45_r_sd           1.39  0.76     0.05  0.03
## lip_sd             28.46  0.68     1.23  0.43
## eye_sd              4.91  0.92     1.44  0.08
## amplitude_sd        0.19  0.68     1.23  0.00
## stage_sd            0.04  1.89     3.95  0.00
## apex_sd             0.07  2.06     7.82  0.00
## offset_sd           0.13  0.89     0.81  0.00
## onset_sd            0.15  0.79     0.77  0.00
## ------------------------------------------------------------ 
## smile_type: spontaneous
## gender: male  
##                   vars   n   mean     sd median trimmed    mad    min    max
## filename*            1 122  61.50  35.36  61.50   61.50  45.22   1.00 122.00
## subject              2 122 290.67 143.53 272.00  289.95 197.93  54.00 525.00
## gender*              3 122   1.00   0.00   1.00    1.00   0.00   1.00   1.00
## age                  4 122  10.53   2.14  10.00   10.24   1.48   8.00  17.00
## smile_type*          5 122   1.00   0.00   1.00    1.00   0.00   1.00   1.00
## frame_min            6 122   1.00   0.00   1.00    1.00   0.00   1.00   1.00
## timestamp_min        7 122   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## gaze_angle_x_min     8 122   0.16   0.09   0.17    0.16   0.09  -0.13   0.39
## gaze_angle_y_min     9 122   0.20   0.09   0.20    0.20   0.08  -0.13   0.38
## pose_Rx_min         10 122   0.08   0.11   0.09    0.09   0.11  -0.22   0.28
## pose_Ry_min         11 122  -0.21   0.10  -0.21   -0.21   0.09  -0.46   0.02
## pose_Rz_min         12 122  -0.05   0.08  -0.04   -0.04   0.07  -0.38   0.13
## AU01_r_min          13 122   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU02_r_min          14 122   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU04_r_min          15 122   0.14   0.38   0.00    0.03   0.00   0.00   1.92
## AU05_r_min          16 122   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU06_r_min          17 122   0.08   0.26   0.00    0.01   0.00   0.00   1.82
## AU07_r_min          18 122   0.21   0.49   0.00    0.08   0.00   0.00   2.50
## AU09_r_min          19 122   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU10_r_min          20 122   0.04   0.14   0.00    0.00   0.00   0.00   0.81
## AU12_r_min          21 122   0.17   0.33   0.00    0.10   0.00   0.00   1.95
## AU14_r_min          22 122   0.48   0.42   0.49    0.44   0.53   0.00   1.85
## AU15_r_min          23 122   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU17_r_min          24 122   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU20_r_min          25 122   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU23_r_min          26 122   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU25_r_min          27 122   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU26_r_min          28 122   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## AU45_r_min          29 122   0.00   0.00   0.00    0.00   0.00   0.00   0.00
## lip_min             30 122 146.44  16.86 146.36  145.97  18.16 109.27 185.49
## eye_min             31 122   5.63   3.52   4.68    5.36   3.39   0.35  15.45
## amplitude_min       32 122   0.34   0.11   0.34    0.34   0.12   0.09   0.60
## stage_min           33 122   0.03   0.01   0.03    0.03   0.01   0.02   0.06
## apex_min            34 122   0.52   0.13   0.53    0.51   0.14   0.29   0.90
## offset_min          35 122   0.38   0.12   0.37    0.37   0.12   0.09   0.63
## onset_min           36 122   0.36   0.11   0.37    0.36   0.12   0.15   0.74
## frame_max           37 122 251.30 110.38 226.50  241.56 101.56  55.00 705.00
## timestamp_max       38 122   5.01   2.21   4.51    4.81   2.03   1.08  14.08
## gaze_angle_x_max    39 122   0.25   0.08   0.25    0.25   0.08   0.02   0.47
## gaze_angle_y_max    40 122   0.39   0.12   0.40    0.40   0.13   0.07   0.62
## pose_Rx_max         41 122   0.21   0.10   0.21    0.21   0.11  -0.06   0.45
## pose_Ry_max         42 122  -0.14   0.10  -0.14   -0.14   0.10  -0.40   0.11
## pose_Rz_max         43 122   0.04   0.07   0.04    0.04   0.07  -0.11   0.26
## AU01_r_max          44 122   0.76   0.63   0.56    0.63   0.34   0.23   4.52
## AU02_r_max          45 122   0.60   0.41   0.47    0.52   0.21   0.16   2.04
## AU04_r_max          46 122   0.61   0.88   0.21    0.43   0.31   0.00   3.56
## AU05_r_max          47 122   0.51   0.26   0.46    0.48   0.22   0.15   1.85
## AU06_r_max          48 122   1.69   0.79   1.63    1.68   0.73   0.00   3.74
## AU07_r_max          49 122   1.84   1.03   1.66    1.78   0.90   0.00   5.00
## AU09_r_max          50 122   0.40   0.25   0.34    0.35   0.18   0.12   1.55
## AU10_r_max          51 122   1.22   0.70   1.31    1.23   0.74   0.00   2.87
## AU12_r_max          52 122   2.70   0.60   2.71    2.72   0.57   1.23   4.05
## AU14_r_max          53 122   1.79   0.50   1.81    1.80   0.43   0.03   3.43
## AU15_r_max          54 122   0.49   0.29   0.41    0.45   0.16   0.19   2.76
## AU17_r_max          55 122   1.22   0.55   1.09    1.17   0.48   0.38   2.82
## AU20_r_max          56 122   0.49   0.21   0.44    0.47   0.20   0.12   1.14
## AU23_r_max          57 122   0.61   0.38   0.53    0.56   0.32   0.10   1.91
## AU25_r_max          58 122   1.25   0.69   1.04    1.16   0.63   0.38   3.46
## AU26_r_max          59 122   1.20   0.68   1.02    1.11   0.41   0.29   4.73
## AU45_r_max          60 122   1.74   1.11   1.55    1.68   1.48   0.25   3.96
## lip_max             61 122 185.98  20.29 187.39  185.88  25.78 146.48 244.90
## eye_max             62 122  12.51   2.43  12.45   12.43   2.25   7.25  22.05
## amplitude_max       63 122   0.61   0.14   0.62    0.61   0.17   0.34   1.00
## stage_max           64 122   0.07   0.03   0.06    0.06   0.02   0.03   0.21
## apex_max            65 122   0.61   0.14   0.62    0.61   0.17   0.34   1.00
## offset_max          66 122   0.51   0.13   0.52    0.51   0.14   0.29   0.90
## onset_max           67 122   0.51   0.13   0.52    0.51   0.14   0.28   0.89
## frame_mean          68 122 126.15  55.19 113.75  121.28  50.78  28.00 353.00
## timestamp_mean      69 122   2.50   1.10   2.26    2.41   1.02   0.54   7.04
## gaze_angle_x_mean   70 122   0.21   0.08   0.21    0.21   0.08  -0.01   0.43
## gaze_angle_y_mean   71 122   0.27   0.08   0.28    0.27   0.08   0.00   0.45
## pose_Rx_mean        72 122   0.15   0.10   0.17    0.16   0.09  -0.11   0.34
## pose_Ry_mean        73 122  -0.18   0.09  -0.18   -0.18   0.09  -0.43   0.05
## pose_Rz_mean        74 122   0.00   0.07  -0.01    0.00   0.07  -0.18   0.19
## AU01_r_mean         75 122   0.12   0.11   0.09    0.10   0.05   0.04   0.95
## AU02_r_mean         76 122   0.06   0.05   0.05    0.05   0.02   0.02   0.29
## AU04_r_mean         77 122   0.32   0.60   0.01    0.17   0.01   0.00   2.70
## AU05_r_mean         78 122   0.04   0.02   0.04    0.04   0.01   0.01   0.12
## AU06_r_mean         79 122   0.93   0.63   0.77    0.88   0.52   0.00   2.95
## AU07_r_mean         80 122   0.99   0.82   0.81    0.89   0.68   0.00   3.63
## AU09_r_mean         81 122   0.05   0.04   0.04    0.04   0.02   0.01   0.30
## AU10_r_mean         82 122   0.61   0.50   0.54    0.57   0.55   0.00   1.84
## AU12_r_mean         83 122   1.79   0.58   1.78    1.78   0.54   0.40   3.38
## AU14_r_mean         84 122   1.23   0.46   1.23    1.24   0.39   0.00   2.81
## AU15_r_mean         85 122   0.08   0.04   0.07    0.07   0.02   0.03   0.30
## AU17_r_mean         86 122   0.32   0.15   0.27    0.30   0.12   0.12   0.87
## AU20_r_mean         87 122   0.06   0.03   0.06    0.06   0.02   0.02   0.16
## AU23_r_mean         88 122   0.08   0.05   0.06    0.07   0.04   0.01   0.26
## AU25_r_mean         89 122   0.43   0.28   0.35    0.40   0.24   0.12   1.70
## AU26_r_mean         90 122   0.32   0.19   0.28    0.29   0.13   0.10   1.41
## AU45_r_mean         91 122   0.16   0.10   0.13    0.15   0.08   0.05   0.48
## lip_mean            92 122 172.02  18.90 173.39  171.86  21.21 138.57 229.63
## eye_mean            93 122  10.36   2.25   9.99   10.21   2.29   5.80  17.31
## amplitude_mean      94 122   0.51   0.13   0.52    0.51   0.14   0.29   0.90
## stage_mean          95 122   0.04   0.01   0.04    0.04   0.01   0.02   0.08
## apex_mean           96 122   0.57   0.13   0.58    0.57   0.15   0.32   0.96
## offset_mean         97 122   0.44   0.12   0.45    0.44   0.13   0.21   0.73
## onset_mean          98 122   0.43   0.12   0.44    0.43   0.13   0.21   0.76
## frame_sd            99 122  72.69  31.86  65.53   69.88  29.32  16.02 203.66
## timestamp_sd       100 122   1.45   0.64   1.31    1.40   0.59   0.32   4.07
## gaze_angle_x_sd    101 122   0.02   0.01   0.02    0.02   0.01   0.00   0.09
## gaze_angle_y_sd    102 122   0.04   0.02   0.04    0.04   0.02   0.01   0.10
## pose_Rx_sd         103 122   0.03   0.02   0.02    0.03   0.01   0.01   0.11
## pose_Ry_sd         104 122   0.02   0.01   0.01    0.02   0.01   0.00   0.07
## pose_Rz_sd         105 122   0.02   0.02   0.02    0.02   0.01   0.00   0.11
## AU01_r_sd          106 122   0.19   0.19   0.14    0.15   0.09   0.05   1.60
## AU02_r_sd          107 122   0.13   0.10   0.10    0.10   0.05   0.04   0.54
## AU04_r_sd          108 122   0.12   0.17   0.03    0.08   0.04   0.00   0.67
## AU05_r_sd          109 122   0.10   0.05   0.09    0.09   0.04   0.03   0.34
## AU06_r_sd          110 122   0.50   0.21   0.49    0.50   0.20   0.00   0.99
## AU07_r_sd          111 122   0.41   0.21   0.40    0.40   0.17   0.00   1.03
## AU09_r_sd          112 122   0.09   0.07   0.07    0.08   0.04   0.02   0.54
## AU10_r_sd          113 122   0.35   0.19   0.38    0.35   0.17   0.00   0.74
## AU12_r_sd          114 122   0.76   0.19   0.75    0.75   0.20   0.32   1.34
## AU14_r_sd          115 122   0.30   0.13   0.26    0.29   0.10   0.01   0.83
## AU15_r_sd          116 122   0.12   0.07   0.10    0.11   0.04   0.05   0.64
## AU17_r_sd          117 122   0.32   0.15   0.29    0.31   0.14   0.10   0.95
## AU20_r_sd          118 122   0.11   0.05   0.10    0.11   0.05   0.03   0.30
## AU23_r_sd          119 122   0.14   0.09   0.12    0.13   0.08   0.03   0.47
## AU25_r_sd          120 122   0.41   0.27   0.31    0.37   0.21   0.11   1.43
## AU26_r_sd          121 122   0.33   0.20   0.28    0.31   0.13   0.09   1.46
## AU45_r_sd          122 122   0.33   0.21   0.28    0.30   0.21   0.06   0.92
## lip_sd             123 122  11.13   3.44  11.07   10.98   3.58   4.95  19.10
## eye_sd             124 122   1.33   0.67   1.31    1.29   0.75   0.23   3.19
## amplitude_sd       125 122   0.07   0.02   0.07    0.07   0.02   0.03   0.13
## stage_sd           126 122   0.01   0.00   0.01    0.01   0.00   0.00   0.02
## apex_sd            127 122   0.03   0.01   0.03    0.02   0.01   0.01   0.05
## offset_sd          128 122   0.04   0.02   0.04    0.04   0.02   0.00   0.13
## onset_sd           129 122   0.04   0.02   0.04    0.04   0.02   0.01   0.11
##                    range  skew kurtosis    se
## filename*         121.00  0.00    -1.23  3.20
## subject           471.00  0.14    -1.37 12.99
## gender*             0.00   NaN      NaN  0.00
## age                 9.00  1.19     0.82  0.19
## smile_type*         0.00   NaN      NaN  0.00
## frame_min           0.00   NaN      NaN  0.00
## timestamp_min       0.00   NaN      NaN  0.00
## gaze_angle_x_min    0.52 -0.52     1.19  0.01
## gaze_angle_y_min    0.51 -0.54     0.85  0.01
## pose_Rx_min         0.51 -0.50    -0.34  0.01
## pose_Ry_min         0.48 -0.14    -0.28  0.01
## pose_Rz_min         0.50 -0.56     1.09  0.01
## AU01_r_min          0.00   NaN      NaN  0.00
## AU02_r_min          0.00   NaN      NaN  0.00
## AU04_r_min          1.92  3.16     9.76  0.03
## AU05_r_min          0.00   NaN      NaN  0.00
## AU06_r_min          1.82  4.31    20.80  0.02
## AU07_r_min          2.50  3.00     9.06  0.04
## AU09_r_min          0.00   NaN      NaN  0.00
## AU10_r_min          0.81  4.21    17.09  0.01
## AU12_r_min          1.95  2.87     9.64  0.03
## AU14_r_min          1.85  0.61    -0.16  0.04
## AU15_r_min          0.00   NaN      NaN  0.00
## AU17_r_min          0.00   NaN      NaN  0.00
## AU20_r_min          0.00   NaN      NaN  0.00
## AU23_r_min          0.00   NaN      NaN  0.00
## AU25_r_min          0.00   NaN      NaN  0.00
## AU26_r_min          0.00   NaN      NaN  0.00
## AU45_r_min          0.00   NaN      NaN  0.00
## lip_min            76.23  0.20    -0.61  1.53
## eye_min            15.10  0.67    -0.41  0.32
## amplitude_min       0.51  0.20    -0.61  0.01
## stage_min           0.04  0.67    -0.47  0.00
## apex_min            0.61  0.15    -0.52  0.01
## offset_min          0.54  0.18    -0.67  0.01
## onset_min           0.59  0.29    -0.14  0.01
## frame_max         650.00  1.13     2.16  9.99
## timestamp_max      13.00  1.13     2.16  0.20
## gaze_angle_x_max    0.44  0.01     0.21  0.01
## gaze_angle_y_max    0.55 -0.23    -0.40  0.01
## pose_Rx_max         0.51 -0.40    -0.14  0.01
## pose_Ry_max         0.51  0.00    -0.23  0.01
## pose_Rz_max         0.37  0.29    -0.16  0.01
## AU01_r_max          4.29  2.94    11.44  0.06
## AU02_r_max          1.88  1.90     3.26  0.04
## AU04_r_max          3.56  1.57     1.59  0.08
## AU05_r_max          1.70  1.76     5.44  0.02
## AU06_r_max          3.74  0.19     0.00  0.07
## AU07_r_max          5.00  0.68     0.46  0.09
## AU09_r_max          1.43  2.23     6.41  0.02
## AU10_r_max          2.87 -0.12    -0.75  0.06
## AU12_r_max          2.82 -0.21    -0.19  0.05
## AU14_r_max          3.40 -0.24     1.32  0.05
## AU15_r_max          2.57  4.07    26.86  0.03
## AU17_r_max          2.44  0.82     0.06  0.05
## AU20_r_max          1.02  0.83     0.18  0.02
## AU23_r_max          1.81  1.23     1.36  0.03
## AU25_r_max          3.08  1.02     0.49  0.06
## AU26_r_max          4.44  2.10     6.50  0.06
## AU45_r_max          3.71  0.27    -1.34  0.10
## lip_max            98.42  0.09    -0.64  1.84
## eye_max            14.80  0.71     1.84  0.22
## amplitude_max       0.66  0.09    -0.64  0.01
## stage_max           0.18  1.82     5.60  0.00
## apex_max            0.66  0.09    -0.64  0.01
## offset_max          0.61  0.12    -0.57  0.01
## onset_max           0.61  0.13    -0.58  0.01
## frame_mean        325.00  1.13     2.16  5.00
## timestamp_mean      6.50  1.13     2.16  0.10
## gaze_angle_x_mean   0.44 -0.01     0.33  0.01
## gaze_angle_y_mean   0.46 -0.53     0.56  0.01
## pose_Rx_mean        0.45 -0.55    -0.19  0.01
## pose_Ry_mean        0.48 -0.09    -0.26  0.01
## pose_Rz_mean        0.36  0.10    -0.35  0.01
## AU01_r_mean         0.92  4.11    22.90  0.01
## AU02_r_mean         0.27  2.84     8.41  0.00
## AU04_r_mean         2.70  2.20     4.33  0.05
## AU05_r_mean         0.11  1.79     4.08  0.00
## AU06_r_mean         2.95  0.84     0.42  0.06
## AU07_r_mean         3.63  1.21     1.39  0.07
## AU09_r_mean         0.29  3.57    16.95  0.00
## AU10_r_mean         1.84  0.58    -0.68  0.04
## AU12_r_mean         2.98  0.08    -0.06  0.05
## AU14_r_mean         2.80 -0.10     0.77  0.04
## AU15_r_mean         0.26  2.41     8.85  0.00
## AU17_r_mean         0.74  1.33     1.70  0.01
## AU20_r_mean         0.14  0.98     0.80  0.00
## AU23_r_mean         0.25  1.26     1.73  0.00
## AU25_r_mean         1.58  1.38     2.45  0.03
## AU26_r_mean         1.32  2.69    10.97  0.02
## AU45_r_mean         0.44  1.36     1.75  0.01
## lip_mean           91.06  0.14    -0.53  1.71
## eye_mean           11.51  0.75     0.54  0.20
## amplitude_mean      0.61  0.14    -0.53  0.01
## stage_mean          0.05  0.80    -0.27  0.00
## apex_mean           0.64  0.13    -0.59  0.01
## offset_mean         0.53  0.04    -0.81  0.01
## onset_mean          0.55  0.06    -0.73  0.01
## frame_sd          187.64  1.13     2.16  2.88
## timestamp_sd        3.75  1.13     2.16  0.06
## gaze_angle_x_sd     0.08  2.50     8.79  0.00
## gaze_angle_y_sd     0.09  1.06     1.35  0.00
## pose_Rx_sd          0.11  1.44     2.43  0.00
## pose_Ry_sd          0.06  1.71     3.43  0.00
## pose_Rz_sd          0.10  2.03     5.09  0.00
## AU01_r_sd           1.55  4.15    23.39  0.02
## AU02_r_sd           0.50  2.46     6.03  0.01
## AU04_r_sd           0.67  1.57     1.72  0.02
## AU05_r_sd           0.31  1.90     4.90  0.00
## AU06_r_sd           0.99 -0.29     0.09  0.02
## AU07_r_sd           1.03  0.29     0.21  0.02
## AU09_r_sd           0.52  3.18    14.01  0.01
## AU10_r_sd           0.74 -0.31    -0.78  0.02
## AU12_r_sd           1.02  0.29    -0.19  0.02
## AU14_r_sd           0.82  0.91     1.49  0.01
## AU15_r_sd           0.60  3.67    22.46  0.01
## AU17_r_sd           0.84  1.04     1.42  0.01
## AU20_r_sd           0.27  0.96     0.67  0.00
## AU23_r_sd           0.45  1.11     0.92  0.01
## AU25_r_sd           1.33  1.18     0.94  0.02
## AU26_r_sd           1.38  2.34     8.78  0.02
## AU45_r_sd           0.85  0.86    -0.11  0.02
## lip_sd             14.15  0.35    -0.45  0.31
## eye_sd              2.96  0.54    -0.21  0.06
## amplitude_sd        0.09  0.35    -0.45  0.00
## stage_sd            0.02  1.22     0.76  0.00
## apex_sd             0.05  0.60     0.11  0.00
## offset_sd           0.13  1.33     2.69  0.00
## onset_sd            0.11  0.79     0.28  0.00
# citation("psych")

Distribution analysis

The main conclusions of the descriptive statistics will be given in the thesis report. The ggplot package is used to create distribution visualization of the distribution of the features.

# loading packages
library(ggplot2)
library(ggpubr)

# age & gender distribution of the video's
ggplot(UvA_sum, aes(y = age, x = smile_type, color = smile_type)) +
  geom_boxplot() +
  scale_y_continuous(name = "Age") +
  scale_x_discrete(name = "Smile Type")

fig1 <- ggplot(UvA_sum, aes(y = age, x = smile_type, color = gender)) +
  geom_boxplot() +
  scale_y_continuous(name = "Age") +
  scale_x_discrete(name = "Smile Type")

ggplot(data = UvA_sum, aes(x = age, fill = smile_type)) +
  geom_bar(stat = "count") +
  scale_x_continuous(
    name = "Age",
    breaks = c(8, 9, 10, 11, 12, 13, 14, 15, 16, 17)
  ) +
  scale_y_continuous(name = "Smile Type") +
  labs() +
  theme(
    legend.position = "bottom", text = element_text(size = 10),
    axis.text = element_text(size = 10)
  )

ggplot(data = UvA_sum, aes(x = age, fill = gender)) +
  geom_bar(stat = "count") +
  scale_x_continuous(
    name = "Age",
    breaks = c(8, 9, 10, 11, 12, 13, 14, 15, 16, 17)
  ) +
  scale_y_continuous(name = "Gender") +
  labs() +
  theme(
    legend.position = "bottom", text = element_text(size = 10),
    axis.text = element_text(size = 10)
  )

fig2 <- ggplot(data = UvA_sum, aes(x = age, fill = smile_type)) +
  geom_bar(stat = "count") +
  scale_x_continuous(
    name = "Age",
    breaks = c(8, 9, 10, 11, 12, 13, 14, 15, 16, 17)
  ) +
  scale_y_continuous(name = "Smile Type") +
  facet_grid(smile_type ~ gender) +
  labs() +
  theme(
    legend.position = "bottom", text = element_text(size = 10),
    axis.text = element_text(size = 10)
  )

# use the ggpubr package to combine multiple ggplot visualizations in one plot
figure <- ggarrange(fig1, fig2,
  # labels = c("1", "2"),
  ncol = 2, nrow = 1
)
figure

# citation("ggpubr")

Check the distributions and any possible outliers, using the mean() and sd().

# distribution per feature

# age
ggplot(UvA_sum, aes(x = age)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = age, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

# frame time
ggplot(UvA_sum, aes(x = frame_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = frame_mean, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4) +
  scale_x_continuous(name = "Frame Mean") +
  scale_y_continuous(name = "Smile Type Count") +
  theme(
    legend.position = "bottom", text = element_text(size = 10),
    axis.text = element_text(size = 10)
  )

# gaze_angle_x
ggplot(UvA_sum, aes(x = gaze_angle_x_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = gaze_angle_x_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(
  UvA_sum,
  aes(x = smile_type, y = gaze_angle_x_mean, color = smile_type)
) +
  geom_boxplot() +
  scale_y_continuous(name = "Gaze x") +
  scale_x_discrete(name = "Smile Type")

# gaze_angle_y
ggplot(UvA_sum, aes(x = gaze_angle_y_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = gaze_angle_y_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(
  UvA_sum,
  aes(x = smile_type, y = gaze_angle_y_mean, color = smile_type)
) +
  geom_boxplot() +
  scale_y_continuous(name = "Gaze y") +
  scale_x_discrete(name = "Smile Type")

# pose_Rx
ggplot(UvA_sum, aes(x = pose_Rx_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = pose_Rx_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = smile_type, y = pose_Rx_mean, color = smile_type)) +
  geom_boxplot() +
  scale_y_continuous(name = "Pose Rx") +
  scale_x_discrete(name = "Smile Type")

# pose_Ry
ggplot(UvA_sum, aes(x = pose_Ry_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = pose_Ry_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = smile_type, y = pose_Ry_mean, color = smile_type)) +
  geom_boxplot() +
  scale_y_continuous(name = "Pose Ry") +
  scale_x_discrete(name = "Smile Type")

# pose_Rz
ggplot(UvA_sum, aes(x = pose_Rz_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = pose_Rz_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = smile_type, y = pose_Rz_mean, color = smile_type)) +
  geom_boxplot() +
  scale_y_continuous(name = "Pose Rz") +
  scale_x_discrete(name = "Smile Type")

# AU01
ggplot(UvA_sum, aes(x = AU01_r_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU01_r_sd, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = AU01_r_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU01_r_mean, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = smile_type, y = AU01_r_mean, color = smile_type)) +
  geom_boxplot() +
  scale_y_continuous(name = "AU01") +
  scale_x_discrete(name = "Smile Type")

# AU02
ggplot(UvA_sum, aes(x = AU02_r_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU02_r_sd, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = AU02_r_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU02_r_mean, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = smile_type, y = AU02_r_mean, color = smile_type)) +
  geom_boxplot() +
  scale_y_continuous(name = "AU02") +
  scale_x_discrete(name = "Smile Type")

# AU04
ggplot(UvA_sum, aes(x = AU04_r_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU04_r_mean, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

# AU04 does not seem to have an impact, as most values show zero value

# AU05
ggplot(UvA_sum, aes(x = AU05_r_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU05_r_sd, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = AU05_r_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU05_r_mean, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = smile_type, y = AU05_r_mean, color = smile_type)) +
  geom_boxplot() +
  scale_y_continuous(name = "AU05") +
  scale_x_discrete(name = "Smile Type")

# AU06
ggplot(UvA_sum, aes(x = AU06_r_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU06_r_sd, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = AU06_r_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU06_r_mean, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = smile_type, y = AU06_r_mean, color = smile_type)) +
  geom_boxplot() +
  scale_y_continuous(name = "AU06") +
  scale_x_discrete(name = "Smile Type")

# AU07
ggplot(UvA_sum, aes(x = AU07_r_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU07_r_sd, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = AU07_r_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU07_r_mean, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = smile_type, y = AU07_r_mean, color = smile_type)) +
  geom_boxplot() +
  scale_y_continuous(name = "AU07") +
  scale_x_discrete(name = "Smile Type")

# AU09
ggplot(UvA_sum, aes(x = AU09_r_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU09_r_sd, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = AU09_r_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU09_r_mean, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = smile_type, y = AU02_r_mean, color = smile_type)) +
  geom_boxplot() +
  scale_y_continuous(name = "AU01") +
  scale_x_discrete(name = "Smile Type")

# AU10
ggplot(UvA_sum, aes(x = AU10_r_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU10_r_sd, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = AU10_r_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU10_r_mean, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = smile_type, y = AU10_r_mean, color = smile_type)) +
  geom_boxplot() +
  scale_y_continuous(name = "AU10") +
  scale_x_discrete(name = "Smile Type")

# AU12
ggplot(UvA_sum, aes(x = AU12_r_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

fig5 <- ggplot(UvA_sum, aes(x = AU12_r_sd, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = AU12_r_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

fig4 <- ggplot(UvA_sum, aes(x = AU12_r_mean, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

fig3 <- ggplot(
  UvA_sum,
  aes(x = smile_type, y = AU12_r_mean, color = smile_type)
) +
  geom_boxplot() +
  scale_y_continuous(name = "AU12") +
  scale_x_discrete(name = "Smile Type")

figure1 <- ggarrange(fig3, fig4, fig5,
  # labels = c("1", "2"),
  ncol = 2, nrow = 2
)
figure1

# AU14
ggplot(UvA_sum, aes(x = AU14_r_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU14_r_sd, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = AU14_r_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU14_r_mean, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = smile_type, y = AU14_r_mean, color = smile_type)) +
  geom_boxplot() +
  scale_y_continuous(name = "AU14") +
  scale_x_discrete(name = "Smile Type")

# AU15
ggplot(UvA_sum, aes(x = AU15_r_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU15_r_sd, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = AU15_r_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU15_r_mean, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = smile_type, y = AU15_r_mean, color = smile_type)) +
  geom_boxplot() +
  scale_y_continuous(name = "AU15") +
  scale_x_discrete(name = "Smile Type")

# AU17
ggplot(UvA_sum, aes(x = AU17_r_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU17_r_sd, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = AU17_r_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU17_r_mean, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = smile_type, y = AU17_r_mean, color = smile_type)) +
  geom_boxplot() +
  scale_y_continuous(name = "AU17") +
  scale_x_discrete(name = "Smile Type")

# AU20
ggplot(UvA_sum, aes(x = AU20_r_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU20_r_sd, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = AU20_r_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU20_r_mean, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = smile_type, y = AU20_r_mean, color = smile_type)) +
  geom_boxplot() +
  scale_y_continuous(name = "AU20") +
  scale_x_discrete(name = "Smile Type")

# AU23
ggplot(UvA_sum, aes(x = AU23_r_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU23_r_sd, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = AU23_r_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU23_r_mean, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = smile_type, y = AU23_r_mean, color = smile_type)) +
  geom_boxplot() +
  scale_y_continuous(name = "AU23") +
  scale_x_discrete(name = "Smile Type")

# AU25
ggplot(UvA_sum, aes(x = AU25_r_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

fig8 <- ggplot(UvA_sum, aes(x = AU25_r_sd, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = AU25_r_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

fig7 <- ggplot(UvA_sum, aes(x = AU25_r_mean, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

fig6 <- ggplot(
  UvA_sum,
  aes(x = smile_type, y = AU25_r_mean, color = smile_type)
) +
  geom_boxplot() +
  scale_y_continuous(name = "AU25") +
  scale_x_discrete(name = "Smile Type")

figure2 <- ggarrange(fig6, fig7, fig8,
  # labels = c("1", "2"),
  ncol = 2, nrow = 2
)
figure2

# AU26
ggplot(UvA_sum, aes(x = AU26_r_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU26_r_sd, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = AU26_r_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU26_r_mean, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = smile_type, y = AU26_r_mean, color = smile_type)) +
  geom_boxplot() +
  scale_y_continuous(name = "AU26") +
  scale_x_discrete(name = "Smile Type")

# AU45
ggplot(UvA_sum, aes(x = AU45_r_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU45_r_sd, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = AU45_r_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = AU45_r_mean, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = smile_type, y = AU45_r_mean, color = smile_type)) +
  geom_boxplot() +
  scale_y_continuous(name = "AU45") +
  scale_x_discrete(name = "Smile Type")

# lip
ggplot(UvA_sum, aes(x = lip_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = lip_sd, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = lip_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = lip_mean, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = smile_type, y = lip_mean, color = smile_type)) +
  geom_boxplot() +
  scale_y_continuous(name = "Lip") +
  scale_x_discrete(name = "Smile Type")

# eye
ggplot(UvA_sum, aes(x = eye_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = eye_sd, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = eye_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = eye_mean, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = smile_type, y = eye_mean, color = smile_type)) +
  geom_boxplot() +
  scale_y_continuous(name = "eye") +
  scale_x_discrete(name = "Smile Type")

# amplitude for onset, apex and offset
ggplot(UvA_sum, aes(x = amplitude_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = amplitude_sd, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = amplitude_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = amplitude_mean, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = smile_type, y = amplitude_mean, color = smile_type)) +
  geom_boxplot() +
  scale_y_continuous(name = "amlitude") +
  scale_x_discrete(name = "Smile Type")

# apex
ggplot(UvA_sum, aes(x = apex_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = apex_sd, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = apex_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = apex_mean, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = smile_type, y = apex_mean, color = smile_type)) +
  geom_boxplot() +
  scale_y_continuous(name = "AU01") +
  scale_x_discrete(name = "Smile Type")

# onset
ggplot(UvA_sum, aes(x = onset_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = onset_sd, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = onset_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = onset_mean, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = smile_type, y = onset_mean, color = smile_type)) +
  geom_boxplot() +
  scale_y_continuous(name = "AU01") +
  scale_x_discrete(name = "Smile Type")

# offset
ggplot(UvA_sum, aes(x = offset_sd)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = offset_sd, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = offset_mean)) +
  geom_histogram(fill = "white", colour = "black") +
  facet_grid(smile_type ~ ., scales = "free")

ggplot(UvA_sum, aes(x = offset_mean, fill = smile_type)) +
  geom_histogram(position = "identity", alpha = 0.4)

ggplot(UvA_sum, aes(x = smile_type, y = offset_mean, color = smile_type)) +
  geom_boxplot() +
  scale_y_continuous(name = "offset") +
  scale_x_discrete(name = "Smile Type")

Some other check plot types to be maybe used later on

# apex vs AU's 6 and 12 for happiness
ggplot(data = UvA_sum, aes(x = AU12_r_mean, y = AU06_r_mean)) +
  geom_point() +
  geom_smooth() +
  scale_x_continuous(
    name = "AU12 ",
  ) +
  scale_y_continuous(name = "AU06") +
  labs() +
  theme(
    legend.position = "bottom", text = element_text(size = 10),
    axis.text = element_text(size = 10)
  )
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

# correlation between eye and lip
ggplot(data = UvA_sum, aes(y = eye_mean, x = lip_mean)) +
  geom_point() +
  geom_smooth()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

# correlation between onset and apex
ggplot(data = UvA_sum, aes(y = onset_mean, x = apex_mean)) +
  geom_point() +
  geom_smooth()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

Part 3: Train, predict and evaluation

The caret package is used to perform the training, testing and evaluation as well the splitting the data. Further explanation of the options and parameter settings of the caret package can be found in the thesis, via the citation link, or ? R help function.

Create data partioning: Train and test set

# set.seed for modeling to 1973 for all models and predictions
set.seed(1973)

# loading packages
library(caret)
library(ggplot2)
library(dplyr)
library(tree)
library(rpart)
library(rpart.plot)
library(rattle)

# remove the filename (or ID) from the modelset to avoid overfilling
UvA_modelset$filename <- NULL
UvA_modelset$smile_type <- as.factor(UvA_modelset$smile_type)
UvA_modelset$gender <- as.factor(UvA_modelset$gender)

# relevel to spontaneous smile
UvA_modelset$smile_type <- relevel(UvA_modelset$smile_type, ref = "spontaneous")

# Split into training and test
set.seed(1973)
trn_index <- createDataPartition(UvA_modelset$smile_type, p = 0.7, list = FALSE)
trn_smile <- UvA_modelset[trn_index, ]
tst_smile <- UvA_modelset[-trn_index, ]

# Split the test set into boys and girls for detecting differences
set.seed(1973)
tst_smile_girls <- tst_smile %>%
  filter(gender == "female")
tst_smile_boys <- tst_smile %>%
  filter(gender == "male  ")

# check the balance in the dataset for the independent variable
table(UvA_modelset$smile_type)
## 
## spontaneous deliberate  
##         235         240
# citation("caret")
# citation("tree")
# citation("rpart")
# citation("rpart.plot")
# citation("ggplot2")
# citation("rattle")

Tain, predict en evaluate models

Decision trees

For the decision trees two packages are explored. For convenience of the project the choice has been made to work with the rpart package over the tree package. More information about these two packages can be found in the citation link or ? R help function. The trained models are divided into eight categories. Multiple models per category are explored. The explanation on the categories can be found in the thesis. To train the models the train() function is used. The models are stored as variable. The parameter settings are explained in the thesis. The models use 10 fold cross-validation. To check the density a visualization is added to the complete model. On this first complete model, also the pre-processing parameter is tested. This is done to see if scaling and centering the the dependent features improves the model. This is not the case for the complete decision tree including all features. The parameter is kept at default for that reason. To visualize the trained decision trees the rattle package is used. The package provides a nicer looking tree. The predict() function is used to create the predictions based on the test set, and stored as variable. For model evaluation the confusionMatrix() function is used and printed.

# check the balance for the baseline model
baseline_model <- table(trn_smile$smile_type)
baseline_model
## 
## spontaneous deliberate  
##         165         168
# model 0: complete model

# set the seed
set.seed(1973)

# train the model using train and rpart, store the model
smile__tree_model_0 <- train(smile_type ~ .,
  method = "rpart", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

# check the outcome of the model
smile__tree_model_0$results
##           cp  Accuracy      Kappa AccuracySD   KappaSD
## 1 0.03636364 0.5370544 0.07672893 0.07505544 0.1510397
## 2 0.05252525 0.5369652 0.07274720 0.07414327 0.1465495
## 3 0.22424242 0.5255849 0.04429576 0.04913641 0.0997257
# check and visualize the variable importance
varImp_0 <- varImp(smile__tree_model_0)
varImp_0
## rpart variable importance
## 
##   only 20 most important variables shown (out of 32)
## 
##                Overall
## AU45_r_mean     100.00
## AU01_r_mean      65.43
## AU25_r_mean      63.30
## apex_mean        59.99
## AU10_r_mean      54.54
## AU05_r_mean      52.28
## amplitude_mean   43.03
## lip_mean         43.03
## AU09_r_mean      40.62
## stage_mean       24.72
## AU14_r_mean      21.58
## AU20_r_mean      15.81
## AU15_r_mean       0.00
## age               0.00
## onset_mean        0.00
## AU23_r_mean       0.00
## AU12_r_mean       0.00
## pose_Ry_mean      0.00
## `gendermale  `    0.00
## AU04_r_mean       0.00
par(mfrow = c(1, 1))
par(mai = c(.8, .8, .2, .2))
plot(varImp_0,
  decreasing = TRUE,
  main = "Variable importance in complex model",
  ylab = "variable importance"
)

# summarize the model details - not printed
# summary(smile__tree_model_0$finalModel)

# visualize the tree using the rattle package
fancyRpartPlot(smile__tree_model_0$finalModel)

# density plot of accuracy measurements, check with the resample data
trellis.par.set(caretTheme())
densityplot(smile__tree_model_0, pch = "|")

smile__tree_model_0$resample
##     Accuracy       Kappa Resample
## 1  0.5151515  0.03649635   Fold02
## 2  0.6363636  0.27737226   Fold01
## 3  0.5757576  0.15693431   Fold03
## 4  0.5757576  0.15073529   Fold06
## 5  0.5882353  0.17647059   Fold05
## 6  0.5000000  0.00000000   Fold04
## 7  0.5454545  0.10163339   Fold07
## 8  0.5882353  0.17647059   Fold10
## 9  0.3750000 -0.25000000   Fold09
## 10 0.4705882 -0.05882353   Fold08
# model 0: complete model with centering and scaling - outcome does not change
set.seed(1973)
smile__tree_model_0.0.1 <- train(smile_type ~ .,
  method = "rpart", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10),
  preProcess = c("center", "scale")
)
smile__tree_model_0.0.1$results
##           cp  Accuracy      Kappa AccuracySD   KappaSD
## 1 0.03636364 0.5370544 0.07672893 0.07505544 0.1510397
## 2 0.05252525 0.5369652 0.07274720 0.07414327 0.1465495
## 3 0.22424242 0.5255849 0.04429576 0.04913641 0.0997257
varImp_0.0.1 <- varImp(smile__tree_model_0.0.1)
varImp_0.0.1
## rpart variable importance
## 
##   only 20 most important variables shown (out of 32)
## 
##                Overall
## AU45_r_mean     100.00
## AU01_r_mean      65.43
## AU25_r_mean      63.30
## apex_mean        59.99
## AU10_r_mean      54.54
## AU05_r_mean      52.28
## amplitude_mean   43.03
## lip_mean         43.03
## AU09_r_mean      40.62
## stage_mean       24.72
## AU14_r_mean      21.58
## AU20_r_mean      15.81
## AU15_r_mean       0.00
## age               0.00
## onset_mean        0.00
## AU23_r_mean       0.00
## AU12_r_mean       0.00
## pose_Ry_mean      0.00
## `gendermale  `    0.00
## AU04_r_mean       0.00
par(mfrow = c(1, 1))
par(mai = c(.8, .8, .2, .2))
plot(varImp_0,
  decreasing = TRUE,
  main = "Variable importance in complex model",
  ylab = "variable importance"
)

# summary(smile__tree_model_0$finalModel)
# visualize the tree using the rattle package
fancyRpartPlot(smile__tree_model_0.0.1$finalModel)

# predict based on the test set and the model, store the model
set.seed(1973)
smile__tree_model_0_pred <- predict(smile__tree_model_0, tst_smile)

# summary of the prediction
summary(smile__tree_model_0_pred)
## spontaneous deliberate  
##          79          63
# create a confusion matrix to evaluate the model
smile__tree_model_0_confM <- confusionMatrix(
  smile__tree_model_0_pred,
  tst_smile$smile_type
)

# print the confusion matrix
smile__tree_model_0_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          42          37
##   deliberate           28          35
##                                           
##                Accuracy : 0.5423          
##                  95% CI : (0.4567, 0.6261)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.2251          
##                                           
##                   Kappa : 0.086           
##                                           
##  Mcnemar's Test P-Value : 0.3211          
##                                           
##             Sensitivity : 0.6000          
##             Specificity : 0.4861          
##          Pos Pred Value : 0.5316          
##          Neg Pred Value : 0.5556          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2958          
##    Detection Prevalence : 0.5563          
##       Balanced Accuracy : 0.5431          
##                                           
##        'Positive' Class : spontaneous     
## 
# same way working for predicting boys and girls
set.seed(1973)
smile__tree_model_0.1_pred <- predict(smile__tree_model_0, tst_smile_boys)
summary(smile__tree_model_0.1_pred)
## spontaneous deliberate  
##          35          42
smile__tree_model_0.1_confM <- confusionMatrix(
  smile__tree_model_0.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_0.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          18          17
##   deliberate           19          23
##                                           
##                Accuracy : 0.5325          
##                  95% CI : (0.4152, 0.6471)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.4552          
##                                           
##                   Kappa : 0.0616          
##                                           
##  Mcnemar's Test P-Value : 0.8676          
##                                           
##             Sensitivity : 0.4865          
##             Specificity : 0.5750          
##          Pos Pred Value : 0.5143          
##          Neg Pred Value : 0.5476          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2338          
##    Detection Prevalence : 0.4545          
##       Balanced Accuracy : 0.5307          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_0.2_pred <- predict(smile__tree_model_0, tst_smile_girls)
summary(smile__tree_model_0.2_pred)
## spontaneous deliberate  
##          44          21
smile__tree_model_0.2_confM <- confusionMatrix(
  smile__tree_model_0.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_0.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          24          20
##   deliberate            9          12
##                                           
##                Accuracy : 0.5538          
##                  95% CI : (0.4253, 0.6773)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.26784         
##                                           
##                   Kappa : 0.1028          
##                                           
##  Mcnemar's Test P-Value : 0.06332         
##                                           
##             Sensitivity : 0.7273          
##             Specificity : 0.3750          
##          Pos Pred Value : 0.5455          
##          Neg Pred Value : 0.5714          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3692          
##    Detection Prevalence : 0.6769          
##       Balanced Accuracy : 0.5511          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 1 onset-apex-offset
set.seed(1973)
smile__tree_model_1 <- train(smile_type ~ onset_mean + offset_mean + apex_mean,
  method = "rpart", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)
smile__tree_model_1$results
##           cp  Accuracy      Kappa AccuracySD   KappaSD
## 1 0.05757576 0.5402184 0.08170716 0.07437569 0.1470887
## 2 0.06262626 0.5373663 0.07391236 0.07093887 0.1393274
## 3 0.06666667 0.5165107 0.03871962 0.06565946 0.1244773
varImp(smile__tree_model_1)
## rpart variable importance
## 
##             Overall
## apex_mean    100.00
## offset_mean   51.79
## onset_mean     0.00
# summary(smile__tree_model_1$finalModel)

fancyRpartPlot(smile__tree_model_1$finalModel)

smile__tree_model_1_pred <- predict(smile__tree_model_1, tst_smile)
summary(smile__tree_model_1_pred)
## spontaneous deliberate  
##          28         114
smile__tree_model_1_confM <- confusionMatrix(
  smile__tree_model_1_pred,
  tst_smile$smile_type
)
smile__tree_model_1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          16          12
##   deliberate           54          60
##                                           
##                Accuracy : 0.5352          
##                  95% CI : (0.4497, 0.6193)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.2786          
##                                           
##                   Kappa : 0.0624          
##                                           
##  Mcnemar's Test P-Value : 4.494e-07       
##                                           
##             Sensitivity : 0.2286          
##             Specificity : 0.8333          
##          Pos Pred Value : 0.5714          
##          Neg Pred Value : 0.5263          
##              Prevalence : 0.4930          
##          Detection Rate : 0.1127          
##    Detection Prevalence : 0.1972          
##       Balanced Accuracy : 0.5310          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_1.1_pred <- predict(smile__tree_model_1, tst_smile_boys)
summary(smile__tree_model_1.1_pred)
## spontaneous deliberate  
##          17          60
smile__tree_model_1.1_confM <- confusionMatrix(
  smile__tree_model_1.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_1.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          10           7
##   deliberate           27          33
##                                           
##                Accuracy : 0.5584          
##                  95% CI : (0.4407, 0.6716)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.28475         
##                                           
##                   Kappa : 0.0972          
##                                           
##  Mcnemar's Test P-Value : 0.00112         
##                                           
##             Sensitivity : 0.2703          
##             Specificity : 0.8250          
##          Pos Pred Value : 0.5882          
##          Neg Pred Value : 0.5500          
##              Prevalence : 0.4805          
##          Detection Rate : 0.1299          
##    Detection Prevalence : 0.2208          
##       Balanced Accuracy : 0.5476          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_1.2_pred <- predict(smile__tree_model_1, tst_smile_girls)
summary(smile__tree_model_1.2_pred)
## spontaneous deliberate  
##          11          54
smile__tree_model_1.2_confM <- confusionMatrix(
  smile__tree_model_1.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_1.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           6           5
##   deliberate           27          27
##                                          
##                Accuracy : 0.5077         
##                  95% CI : (0.3807, 0.634)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.5495482      
##                                          
##                   Kappa : 0.0253         
##                                          
##  Mcnemar's Test P-Value : 0.0002054      
##                                          
##             Sensitivity : 0.18182        
##             Specificity : 0.84375        
##          Pos Pred Value : 0.54545        
##          Neg Pred Value : 0.50000        
##              Prevalence : 0.50769        
##          Detection Rate : 0.09231        
##    Detection Prevalence : 0.16923        
##       Balanced Accuracy : 0.51278        
##                                          
##        'Positive' Class : spontaneous    
## 
# model 1A onset
set.seed(1973)
smile__tree_model_1A <- train(smile_type ~ onset_mean,
  method = "rpart", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)
smile__tree_model_1A$results
##           cp  Accuracy        Kappa AccuracySD    KappaSD
## 1 0.01515152 0.4710060 -0.055638375 0.08058915 0.15999168
## 2 0.02424242 0.4741254 -0.051455995 0.05907009 0.11360546
## 3 0.04242424 0.4986631 -0.005634066 0.04641479 0.08338809
# summary(smile__tree_model_1A$finalModel)

smile__tree_model_1A_pred <- predict(smile__tree_model_1A, tst_smile)
summary(smile__tree_model_1A_pred)
## spontaneous deliberate  
##           0         142
smile__tree_model_1A_confM <- confusionMatrix(
  smile__tree_model_1A_pred,
  tst_smile$smile_type
)
smile__tree_model_1A_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           0           0
##   deliberate           70          72
##                                           
##                Accuracy : 0.507           
##                  95% CI : (0.4219, 0.5919)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.5336          
##                                           
##                   Kappa : 0               
##                                           
##  Mcnemar's Test P-Value : <2e-16          
##                                           
##             Sensitivity : 0.000           
##             Specificity : 1.000           
##          Pos Pred Value :   NaN           
##          Neg Pred Value : 0.507           
##              Prevalence : 0.493           
##          Detection Rate : 0.000           
##    Detection Prevalence : 0.000           
##       Balanced Accuracy : 0.500           
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_1A.1_pred <- predict(smile__tree_model_1A, tst_smile_boys)
summary(smile__tree_model_1A.1_pred)
## spontaneous deliberate  
##           0          77
smile__tree_model_1A.1_confM <- confusionMatrix(
  smile__tree_model_1A.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_1A.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           0           0
##   deliberate           37          40
##                                           
##                Accuracy : 0.5195          
##                  95% CI : (0.4026, 0.6348)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.5459          
##                                           
##                   Kappa : 0               
##                                           
##  Mcnemar's Test P-Value : 3.252e-09       
##                                           
##             Sensitivity : 0.0000          
##             Specificity : 1.0000          
##          Pos Pred Value :    NaN          
##          Neg Pred Value : 0.5195          
##              Prevalence : 0.4805          
##          Detection Rate : 0.0000          
##    Detection Prevalence : 0.0000          
##       Balanced Accuracy : 0.5000          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_1A.2_pred <- predict(smile__tree_model_1A, tst_smile_girls)
summary(smile__tree_model_1A.2_pred)
## spontaneous deliberate  
##           0          65
smile__tree_model_1A.2_confM <- confusionMatrix(
  smile__tree_model_1A.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_1A.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           0           0
##   deliberate           33          32
##                                          
##                Accuracy : 0.4923         
##                  95% CI : (0.366, 0.6193)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.6452         
##                                          
##                   Kappa : 0              
##                                          
##  Mcnemar's Test P-Value : 2.54e-08       
##                                          
##             Sensitivity : 0.0000         
##             Specificity : 1.0000         
##          Pos Pred Value :    NaN         
##          Neg Pred Value : 0.4923         
##              Prevalence : 0.5077         
##          Detection Rate : 0.0000         
##    Detection Prevalence : 0.0000         
##       Balanced Accuracy : 0.5000         
##                                          
##        'Positive' Class : spontaneous    
## 
# model 1B apex
set.seed(1973)
smile__tree_model_1B <- train(smile_type ~ apex_mean,
  method = "rpart", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)
smile__tree_model_1B$results
##           cp  Accuracy       Kappa AccuracySD   KappaSD
## 1 0.01818182 0.4931540 -0.01455893 0.06234358 0.1266862
## 2 0.02121212 0.4928866 -0.01707760 0.06605422 0.1333608
## 3 0.11515152 0.4866310 -0.03605245 0.03749912 0.0690707
# summary(smile__tree_model_1B$finalModel)

smile__tree_model_1B_pred <- predict(smile__tree_model_1B, tst_smile)
summary(smile__tree_model_1B_pred)
## spontaneous deliberate  
##          23         119
smile__tree_model_1B_confM <- confusionMatrix(
  smile__tree_model_1B_pred,
  tst_smile$smile_type
)
smile__tree_model_1B_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          13          10
##   deliberate           57          62
##                                           
##                Accuracy : 0.5282          
##                  95% CI : (0.4427, 0.6124)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.3376          
##                                           
##                   Kappa : 0.0473          
##                                           
##  Mcnemar's Test P-Value : 1.912e-08       
##                                           
##             Sensitivity : 0.18571         
##             Specificity : 0.86111         
##          Pos Pred Value : 0.56522         
##          Neg Pred Value : 0.52101         
##              Prevalence : 0.49296         
##          Detection Rate : 0.09155         
##    Detection Prevalence : 0.16197         
##       Balanced Accuracy : 0.52341         
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_1B.1_pred <- predict(smile__tree_model_1B, tst_smile_boys)
summary(smile__tree_model_1B.1_pred)
## spontaneous deliberate  
##          14          63
smile__tree_model_1B.1_confM <- confusionMatrix(
  smile__tree_model_1B.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_1B.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           9           5
##   deliberate           28          35
##                                           
##                Accuracy : 0.5714          
##                  95% CI : (0.4535, 0.6837)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.2125930       
##                                           
##                   Kappa : 0.1211          
##                                           
##  Mcnemar's Test P-Value : 0.0001283       
##                                           
##             Sensitivity : 0.2432          
##             Specificity : 0.8750          
##          Pos Pred Value : 0.6429          
##          Neg Pred Value : 0.5556          
##              Prevalence : 0.4805          
##          Detection Rate : 0.1169          
##    Detection Prevalence : 0.1818          
##       Balanced Accuracy : 0.5591          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_1B.2_pred <- predict(smile__tree_model_1B, tst_smile_girls)
summary(smile__tree_model_1B.2_pred)
## spontaneous deliberate  
##           9          56
smile__tree_model_1B.2_confM <- confusionMatrix(
  smile__tree_model_1B.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_1B.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           4           5
##   deliberate           29          27
##                                           
##                Accuracy : 0.4769          
##                  95% CI : (0.3515, 0.6046)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.7324          
##                                           
##                   Kappa : -0.0346         
##                                           
##  Mcnemar's Test P-Value : 7.998e-05       
##                                           
##             Sensitivity : 0.12121         
##             Specificity : 0.84375         
##          Pos Pred Value : 0.44444         
##          Neg Pred Value : 0.48214         
##              Prevalence : 0.50769         
##          Detection Rate : 0.06154         
##    Detection Prevalence : 0.13846         
##       Balanced Accuracy : 0.48248         
##                                           
##        'Positive' Class : spontaneous     
## 
# model 1C offset
set.seed(1973)
smile__tree_model_1C <- train(smile_type ~ offset_mean,
  method = "rpart", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)
smile__tree_model_1C$results
##           cp  Accuracy        Kappa AccuracySD    KappaSD
## 1 0.01515152 0.4804924 -0.035544289 0.08003429 0.15971621
## 2 0.02424242 0.4951036 -0.005294115 0.07130717 0.14356728
## 3 0.06666667 0.5014316  0.016202110 0.03203681 0.05735123
# summary(smile__tree_model_1C$finalModel)

smile__tree_model_1C_pred <- predict(smile__tree_model_1C, tst_smile)
summary(smile__tree_model_1C_pred)
## spontaneous deliberate  
##           0         142
smile__tree_model_1C_confM <- confusionMatrix(
  smile__tree_model_1C_pred,
  tst_smile$smile_type
)
smile__tree_model_1C_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           0           0
##   deliberate           70          72
##                                           
##                Accuracy : 0.507           
##                  95% CI : (0.4219, 0.5919)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.5336          
##                                           
##                   Kappa : 0               
##                                           
##  Mcnemar's Test P-Value : <2e-16          
##                                           
##             Sensitivity : 0.000           
##             Specificity : 1.000           
##          Pos Pred Value :   NaN           
##          Neg Pred Value : 0.507           
##              Prevalence : 0.493           
##          Detection Rate : 0.000           
##    Detection Prevalence : 0.000           
##       Balanced Accuracy : 0.500           
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_1C.1_pred <- predict(smile__tree_model_1C, tst_smile_boys)
summary(smile__tree_model_1C.1_pred)
## spontaneous deliberate  
##           0          77
smile__tree_model_1C.1_confM <- confusionMatrix(
  smile__tree_model_1C.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_1C.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           0           0
##   deliberate           37          40
##                                           
##                Accuracy : 0.5195          
##                  95% CI : (0.4026, 0.6348)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.5459          
##                                           
##                   Kappa : 0               
##                                           
##  Mcnemar's Test P-Value : 3.252e-09       
##                                           
##             Sensitivity : 0.0000          
##             Specificity : 1.0000          
##          Pos Pred Value :    NaN          
##          Neg Pred Value : 0.5195          
##              Prevalence : 0.4805          
##          Detection Rate : 0.0000          
##    Detection Prevalence : 0.0000          
##       Balanced Accuracy : 0.5000          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_1C.2_pred <- predict(smile__tree_model_1C, tst_smile_girls)
summary(smile__tree_model_1C.2_pred)
## spontaneous deliberate  
##           0          65
smile__tree_model_1C.2_confM <- confusionMatrix(
  smile__tree_model_1C.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_1C.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           0           0
##   deliberate           33          32
##                                          
##                Accuracy : 0.4923         
##                  95% CI : (0.366, 0.6193)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.6452         
##                                          
##                   Kappa : 0              
##                                          
##  Mcnemar's Test P-Value : 2.54e-08       
##                                          
##             Sensitivity : 0.0000         
##             Specificity : 1.0000         
##          Pos Pred Value :    NaN         
##          Neg Pred Value : 0.4923         
##              Prevalence : 0.5077         
##          Detection Rate : 0.0000         
##    Detection Prevalence : 0.0000         
##       Balanced Accuracy : 0.5000         
##                                          
##        'Positive' Class : spontaneous    
## 
# model 2 complete excluding subject and age info
set.seed(1973)
smile__tree_model_2 <- train(smile_type ~ . - subject - age,
  method = "rpart", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_2$results
##           cp  Accuracy      Kappa AccuracySD   KappaSD
## 1 0.03636364 0.5458779 0.09437598 0.07540099 0.1513876
## 2 0.05252525 0.5369652 0.07274720 0.07414327 0.1465495
## 3 0.22424242 0.5255849 0.04429576 0.04913641 0.0997257
varImp(smile__tree_model_2)
## rpart variable importance
## 
##   only 20 most important variables shown (out of 30)
## 
##                   Overall
## AU45_r_mean        100.00
## AU01_r_mean         65.43
## AU25_r_mean         63.30
## apex_mean           59.99
## AU10_r_mean         54.54
## AU05_r_mean         52.28
## amplitude_mean      43.03
## lip_mean            43.03
## AU09_r_mean         40.62
## stage_mean          24.72
## AU14_r_mean         21.58
## AU20_r_mean         15.81
## AU23_r_mean          0.00
## gaze_angle_y_mean    0.00
## eye_mean             0.00
## AU17_r_mean          0.00
## AU02_r_mean          0.00
## gaze_angle_x_mean    0.00
## AU07_r_mean          0.00
## `gendermale  `       0.00
# summary(smile__tree_model_2$finalModel)
fancyRpartPlot(smile__tree_model_2$finalModel)

smile__tree_model_2_pred <- predict(smile__tree_model_2, tst_smile)
summary(smile__tree_model_2_pred)
## spontaneous deliberate  
##          79          63
smile__tree_model_2_confM <- confusionMatrix(
  smile__tree_model_2_pred,
  tst_smile$smile_type
)
smile__tree_model_2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          42          37
##   deliberate           28          35
##                                           
##                Accuracy : 0.5423          
##                  95% CI : (0.4567, 0.6261)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.2251          
##                                           
##                   Kappa : 0.086           
##                                           
##  Mcnemar's Test P-Value : 0.3211          
##                                           
##             Sensitivity : 0.6000          
##             Specificity : 0.4861          
##          Pos Pred Value : 0.5316          
##          Neg Pred Value : 0.5556          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2958          
##    Detection Prevalence : 0.5563          
##       Balanced Accuracy : 0.5431          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_2.1_pred <- predict(smile__tree_model_2, tst_smile_boys)
summary(smile__tree_model_2.1_pred)
## spontaneous deliberate  
##          35          42
smile__tree_model_2.1_confM <- confusionMatrix(
  smile__tree_model_2.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_2.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          18          17
##   deliberate           19          23
##                                           
##                Accuracy : 0.5325          
##                  95% CI : (0.4152, 0.6471)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.4552          
##                                           
##                   Kappa : 0.0616          
##                                           
##  Mcnemar's Test P-Value : 0.8676          
##                                           
##             Sensitivity : 0.4865          
##             Specificity : 0.5750          
##          Pos Pred Value : 0.5143          
##          Neg Pred Value : 0.5476          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2338          
##    Detection Prevalence : 0.4545          
##       Balanced Accuracy : 0.5307          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_2.2_pred <- predict(smile__tree_model_2, tst_smile_girls)
summary(smile__tree_model_2.2_pred)
## spontaneous deliberate  
##          44          21
smile__tree_model_2.2_confM <- confusionMatrix(
  smile__tree_model_2.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_2.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          24          20
##   deliberate            9          12
##                                           
##                Accuracy : 0.5538          
##                  95% CI : (0.4253, 0.6773)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.26784         
##                                           
##                   Kappa : 0.1028          
##                                           
##  Mcnemar's Test P-Value : 0.06332         
##                                           
##             Sensitivity : 0.7273          
##             Specificity : 0.3750          
##          Pos Pred Value : 0.5455          
##          Neg Pred Value : 0.5714          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3692          
##    Detection Prevalence : 0.6769          
##       Balanced Accuracy : 0.5511          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 3 complete lip and eye features
set.seed(1973)
smile__tree_model_3 <- train(smile_type ~ lip_mean + eye_mean,
  method = "rpart", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_3$results
##           cp  Accuracy       Kappa AccuracySD    KappaSD
## 1 0.01515152 0.5526738  0.10440266 0.09180319 0.18217867
## 2 0.06666667 0.5892435  0.17469528 0.10479850 0.21101409
## 3 0.16363636 0.4868093 -0.03388104 0.03960046 0.07404332
varImp(smile__tree_model_3)
## rpart variable importance
## 
##          Overall
## eye_mean     100
## lip_mean       0
# summary(smile__tree_model_3$finalModel)
fancyRpartPlot(smile__tree_model_3$finalModel)

smile__tree_model_3_pred <- predict(smile__tree_model_3, tst_smile)
summary(smile__tree_model_3_pred)
## spontaneous deliberate  
##          41         101
smile__tree_model_3_confM <- confusionMatrix(
  smile__tree_model_3_pred,
  tst_smile$smile_type
)
smile__tree_model_3_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          25          16
##   deliberate           45          56
##                                           
##                Accuracy : 0.5704          
##                  95% CI : (0.4847, 0.6531)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.076642        
##                                           
##                   Kappa : 0.1357          
##                                           
##  Mcnemar's Test P-Value : 0.000337        
##                                           
##             Sensitivity : 0.3571          
##             Specificity : 0.7778          
##          Pos Pred Value : 0.6098          
##          Neg Pred Value : 0.5545          
##              Prevalence : 0.4930          
##          Detection Rate : 0.1761          
##    Detection Prevalence : 0.2887          
##       Balanced Accuracy : 0.5675          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_3.1_pred <- predict(smile__tree_model_3, tst_smile_boys)
summary(smile__tree_model_3.1_pred)
## spontaneous deliberate  
##          22          55
smile__tree_model_3.1_confM <- confusionMatrix(
  smile__tree_model_3.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_3.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          13           9
##   deliberate           24          31
##                                           
##                Accuracy : 0.5714          
##                  95% CI : (0.4535, 0.6837)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.21259         
##                                           
##                   Kappa : 0.1283          
##                                           
##  Mcnemar's Test P-Value : 0.01481         
##                                           
##             Sensitivity : 0.3514          
##             Specificity : 0.7750          
##          Pos Pred Value : 0.5909          
##          Neg Pred Value : 0.5636          
##              Prevalence : 0.4805          
##          Detection Rate : 0.1688          
##    Detection Prevalence : 0.2857          
##       Balanced Accuracy : 0.5632          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_3.2_pred <- predict(smile__tree_model_3, tst_smile_girls)
summary(smile__tree_model_3.2_pred)
## spontaneous deliberate  
##          19          46
smile__tree_model_3.2_confM <- confusionMatrix(
  smile__tree_model_3.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_3.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          12           7
##   deliberate           21          25
##                                           
##                Accuracy : 0.5692          
##                  95% CI : (0.4404, 0.6915)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.19273         
##                                           
##                   Kappa : 0.1439          
##                                           
##  Mcnemar's Test P-Value : 0.01402         
##                                           
##             Sensitivity : 0.3636          
##             Specificity : 0.7812          
##          Pos Pred Value : 0.6316          
##          Neg Pred Value : 0.5435          
##              Prevalence : 0.5077          
##          Detection Rate : 0.1846          
##    Detection Prevalence : 0.2923          
##       Balanced Accuracy : 0.5724          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 3A lip
set.seed(1973)
smile__tree_model_3A <- train(smile_type ~ lip_mean,
  method = "rpart", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_3A$results
##           cp  Accuracy       Kappa AccuracySD    KappaSD
## 1 0.02121212 0.4811943 -0.03738362 0.09195689 0.18310126
## 2 0.02424242 0.4667725 -0.06529158 0.09635085 0.19215722
## 3 0.09090909 0.4836898 -0.03924734 0.04451978 0.08362762
# summary(smile__tree_model_3A$finalModel)

smile__tree_model_3A_pred <- predict(smile__tree_model_3A, tst_smile)
summary(smile__tree_model_3A_pred)
## spontaneous deliberate  
##           0         142
smile__tree_model_3A_confM <- confusionMatrix(
  smile__tree_model_3A_pred,
  tst_smile$smile_type
)
smile__tree_model_3A_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           0           0
##   deliberate           70          72
##                                           
##                Accuracy : 0.507           
##                  95% CI : (0.4219, 0.5919)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.5336          
##                                           
##                   Kappa : 0               
##                                           
##  Mcnemar's Test P-Value : <2e-16          
##                                           
##             Sensitivity : 0.000           
##             Specificity : 1.000           
##          Pos Pred Value :   NaN           
##          Neg Pred Value : 0.507           
##              Prevalence : 0.493           
##          Detection Rate : 0.000           
##    Detection Prevalence : 0.000           
##       Balanced Accuracy : 0.500           
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_3A.1_pred <- predict(smile__tree_model_3A, tst_smile_boys)
summary(smile__tree_model_3A.1_pred)
## spontaneous deliberate  
##           0          77
smile__tree_model_3A.1_confM <- confusionMatrix(
  smile__tree_model_3A.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_3A.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           0           0
##   deliberate           37          40
##                                           
##                Accuracy : 0.5195          
##                  95% CI : (0.4026, 0.6348)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.5459          
##                                           
##                   Kappa : 0               
##                                           
##  Mcnemar's Test P-Value : 3.252e-09       
##                                           
##             Sensitivity : 0.0000          
##             Specificity : 1.0000          
##          Pos Pred Value :    NaN          
##          Neg Pred Value : 0.5195          
##              Prevalence : 0.4805          
##          Detection Rate : 0.0000          
##    Detection Prevalence : 0.0000          
##       Balanced Accuracy : 0.5000          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_3A.2_pred <- predict(smile__tree_model_3A, tst_smile_girls)
summary(smile__tree_model_3A.2_pred)
## spontaneous deliberate  
##           0          65
smile__tree_model_3A.2_confM <- confusionMatrix(
  smile__tree_model_3A.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_3A.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           0           0
##   deliberate           33          32
##                                          
##                Accuracy : 0.4923         
##                  95% CI : (0.366, 0.6193)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.6452         
##                                          
##                   Kappa : 0              
##                                          
##  Mcnemar's Test P-Value : 2.54e-08       
##                                          
##             Sensitivity : 0.0000         
##             Specificity : 1.0000         
##          Pos Pred Value :    NaN         
##          Neg Pred Value : 0.4923         
##              Prevalence : 0.5077         
##          Detection Rate : 0.0000         
##    Detection Prevalence : 0.0000         
##       Balanced Accuracy : 0.5000         
##                                          
##        'Positive' Class : spontaneous    
## 
# model 3B eye
set.seed(1973)
smile__tree_model_3B <- train(smile_type ~ eye_mean,
  method = "rpart", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_3B$results
##           cp  Accuracy       Kappa AccuracySD    KappaSD
## 1 0.03030303 0.5889706  0.17587312 0.07422087 0.14742791
## 2 0.06666667 0.5892435  0.17469528 0.10479850 0.21101409
## 3 0.16363636 0.4868093 -0.03388104 0.03960046 0.07404332
# summary(smile__tree_model_3B$finalModel)

smile__tree_model_3B_pred <- predict(smile__tree_model_3B, tst_smile)
summary(smile__tree_model_3B_pred)
## spontaneous deliberate  
##          41         101
smile__tree_model_3B_confM <- confusionMatrix(
  smile__tree_model_3B_pred,
  tst_smile$smile_type
)
smile__tree_model_3B_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          25          16
##   deliberate           45          56
##                                           
##                Accuracy : 0.5704          
##                  95% CI : (0.4847, 0.6531)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.076642        
##                                           
##                   Kappa : 0.1357          
##                                           
##  Mcnemar's Test P-Value : 0.000337        
##                                           
##             Sensitivity : 0.3571          
##             Specificity : 0.7778          
##          Pos Pred Value : 0.6098          
##          Neg Pred Value : 0.5545          
##              Prevalence : 0.4930          
##          Detection Rate : 0.1761          
##    Detection Prevalence : 0.2887          
##       Balanced Accuracy : 0.5675          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_3B.1_pred <- predict(smile__tree_model_3B, tst_smile_boys)
summary(smile__tree_model_3B.1_pred)
## spontaneous deliberate  
##          22          55
smile__tree_model_3B.1_confM <- confusionMatrix(
  smile__tree_model_3B.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_3B.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          13           9
##   deliberate           24          31
##                                           
##                Accuracy : 0.5714          
##                  95% CI : (0.4535, 0.6837)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.21259         
##                                           
##                   Kappa : 0.1283          
##                                           
##  Mcnemar's Test P-Value : 0.01481         
##                                           
##             Sensitivity : 0.3514          
##             Specificity : 0.7750          
##          Pos Pred Value : 0.5909          
##          Neg Pred Value : 0.5636          
##              Prevalence : 0.4805          
##          Detection Rate : 0.1688          
##    Detection Prevalence : 0.2857          
##       Balanced Accuracy : 0.5632          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_3B.2_pred <- predict(smile__tree_model_3B, tst_smile_girls)
summary(smile__tree_model_3B.2_pred)
## spontaneous deliberate  
##          19          46
smile__tree_model_3B.2_confM <- confusionMatrix(
  smile__tree_model_3B.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_3B.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          12           7
##   deliberate           21          25
##                                           
##                Accuracy : 0.5692          
##                  95% CI : (0.4404, 0.6915)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.19273         
##                                           
##                   Kappa : 0.1439          
##                                           
##  Mcnemar's Test P-Value : 0.01402         
##                                           
##             Sensitivity : 0.3636          
##             Specificity : 0.7812          
##          Pos Pred Value : 0.6316          
##          Neg Pred Value : 0.5435          
##              Prevalence : 0.5077          
##          Detection Rate : 0.1846          
##    Detection Prevalence : 0.2923          
##       Balanced Accuracy : 0.5724          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 3C complete lip, amplitude, and eye features
set.seed(1973)
smile__tree_model_3C <- train(smile_type ~ lip_mean + eye_mean + amplitude_mean,
  method = "rpart", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_3C$results
##           cp  Accuracy       Kappa AccuracySD    KappaSD
## 1 0.01515152 0.5526738  0.10440266 0.09180319 0.18217867
## 2 0.06666667 0.5892435  0.17469528 0.10479850 0.21101409
## 3 0.16363636 0.4868093 -0.03388104 0.03960046 0.07404332
varImp(smile__tree_model_3C)
## rpart variable importance
## 
##                Overall
## eye_mean           100
## amplitude_mean       0
## lip_mean             0
# summary(smile__tree_model_3C$finalModel)
fancyRpartPlot(smile__tree_model_3C$finalModel)

smile__tree_model_3C_pred <- predict(smile__tree_model_3C, tst_smile)
summary(smile__tree_model_3C_pred)
## spontaneous deliberate  
##          41         101
smile__tree_model_3C_confM <- confusionMatrix(
  smile__tree_model_3C_pred,
  tst_smile$smile_type
)
smile__tree_model_3C_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          25          16
##   deliberate           45          56
##                                           
##                Accuracy : 0.5704          
##                  95% CI : (0.4847, 0.6531)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.076642        
##                                           
##                   Kappa : 0.1357          
##                                           
##  Mcnemar's Test P-Value : 0.000337        
##                                           
##             Sensitivity : 0.3571          
##             Specificity : 0.7778          
##          Pos Pred Value : 0.6098          
##          Neg Pred Value : 0.5545          
##              Prevalence : 0.4930          
##          Detection Rate : 0.1761          
##    Detection Prevalence : 0.2887          
##       Balanced Accuracy : 0.5675          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_3C.1_pred <- predict(smile__tree_model_3C, tst_smile_boys)
summary(smile__tree_model_3C.1_pred)
## spontaneous deliberate  
##          22          55
smile__tree_model_3C.1_confM <- confusionMatrix(
  smile__tree_model_3C.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_3C.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          13           9
##   deliberate           24          31
##                                           
##                Accuracy : 0.5714          
##                  95% CI : (0.4535, 0.6837)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.21259         
##                                           
##                   Kappa : 0.1283          
##                                           
##  Mcnemar's Test P-Value : 0.01481         
##                                           
##             Sensitivity : 0.3514          
##             Specificity : 0.7750          
##          Pos Pred Value : 0.5909          
##          Neg Pred Value : 0.5636          
##              Prevalence : 0.4805          
##          Detection Rate : 0.1688          
##    Detection Prevalence : 0.2857          
##       Balanced Accuracy : 0.5632          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_3C.2_pred <- predict(smile__tree_model_3C, tst_smile_girls)
summary(smile__tree_model_3C.2_pred)
## spontaneous deliberate  
##          19          46
smile__tree_model_3C.2_confM <- confusionMatrix(
  smile__tree_model_3C.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_3C.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          12           7
##   deliberate           21          25
##                                           
##                Accuracy : 0.5692          
##                  95% CI : (0.4404, 0.6915)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.19273         
##                                           
##                   Kappa : 0.1439          
##                                           
##  Mcnemar's Test P-Value : 0.01402         
##                                           
##             Sensitivity : 0.3636          
##             Specificity : 0.7812          
##          Pos Pred Value : 0.6316          
##          Neg Pred Value : 0.5435          
##              Prevalence : 0.5077          
##          Detection Rate : 0.1846          
##    Detection Prevalence : 0.2923          
##       Balanced Accuracy : 0.5724          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 4 AU features complete model
set.seed(1973)
smile__tree_model_4 <- train(smile_type ~ AU01_r_mean + AU02_r_mean +
  AU04_r_mean + AU05_r_mean + AU06_r_mean +
  AU07_r_mean + AU09_r_mean + AU10_r_mean +
  AU12_r_mean + AU14_r_mean + AU15_r_mean +
  AU17_r_mean + AU20_r_mean + AU23_r_mean +
  AU25_r_mean + AU26_r_mean + AU45_r_mean,
method = "rpart", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_4$results
##           cp  Accuracy      Kappa AccuracySD   KappaSD
## 1 0.03030303 0.5636141 0.12907456 0.08437636 0.1685849
## 2 0.05252525 0.5308155 0.05932530 0.07759515 0.1551832
## 3 0.22424242 0.5255849 0.04429576 0.04913641 0.0997257
smile__tree_model_4$coefnames
##  [1] "AU01_r_mean" "AU02_r_mean" "AU04_r_mean" "AU05_r_mean" "AU06_r_mean"
##  [6] "AU07_r_mean" "AU09_r_mean" "AU10_r_mean" "AU12_r_mean" "AU14_r_mean"
## [11] "AU15_r_mean" "AU17_r_mean" "AU20_r_mean" "AU23_r_mean" "AU25_r_mean"
## [16] "AU26_r_mean" "AU45_r_mean"
varImp(smile__tree_model_4)
## rpart variable importance
## 
##             Overall
## AU45_r_mean  100.00
## AU01_r_mean   81.66
## AU25_r_mean   77.78
## AU09_r_mean   73.78
## AU10_r_mean   54.54
## AU05_r_mean   52.28
## AU14_r_mean   21.58
## AU12_r_mean    0.00
## AU23_r_mean    0.00
## AU07_r_mean    0.00
## AU02_r_mean    0.00
## AU04_r_mean    0.00
## AU06_r_mean    0.00
## AU17_r_mean    0.00
## AU20_r_mean    0.00
## AU26_r_mean    0.00
## AU15_r_mean    0.00
# summary(smile__tree_model_4$finalModel)
fancyRpartPlot(smile__tree_model_4$finalModel)

smile__tree_model_4_pred <- predict(smile__tree_model_4, tst_smile)
summary(smile__tree_model_4_pred)
## spontaneous deliberate  
##          84          58
smile__tree_model_4_confM <- confusionMatrix(
  smile__tree_model_4_pred,
  tst_smile$smile_type
)
smile__tree_model_4_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          44          40
##   deliberate           26          32
##                                           
##                Accuracy : 0.5352          
##                  95% CI : (0.4497, 0.6193)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.2786          
##                                           
##                   Kappa : 0.0728          
##                                           
##  Mcnemar's Test P-Value : 0.1096          
##                                           
##             Sensitivity : 0.6286          
##             Specificity : 0.4444          
##          Pos Pred Value : 0.5238          
##          Neg Pred Value : 0.5517          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3099          
##    Detection Prevalence : 0.5915          
##       Balanced Accuracy : 0.5365          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_4.1_pred <- predict(smile__tree_model_4, tst_smile_boys)
summary(smile__tree_model_4.1_pred)
## spontaneous deliberate  
##          40          37
smile__tree_model_4.1_confM <- confusionMatrix(
  smile__tree_model_4.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_4.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          20          20
##   deliberate           17          20
##                                           
##                Accuracy : 0.5195          
##                  95% CI : (0.4026, 0.6348)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.5459          
##                                           
##                   Kappa : 0.0404          
##                                           
##  Mcnemar's Test P-Value : 0.7423          
##                                           
##             Sensitivity : 0.5405          
##             Specificity : 0.5000          
##          Pos Pred Value : 0.5000          
##          Neg Pred Value : 0.5405          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2597          
##    Detection Prevalence : 0.5195          
##       Balanced Accuracy : 0.5203          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_4.2_pred <- predict(smile__tree_model_4, tst_smile_girls)
summary(smile__tree_model_4.2_pred)
## spontaneous deliberate  
##          44          21
smile__tree_model_4.2_confM <- confusionMatrix(
  smile__tree_model_4.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_4.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          24          20
##   deliberate            9          12
##                                           
##                Accuracy : 0.5538          
##                  95% CI : (0.4253, 0.6773)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.26784         
##                                           
##                   Kappa : 0.1028          
##                                           
##  Mcnemar's Test P-Value : 0.06332         
##                                           
##             Sensitivity : 0.7273          
##             Specificity : 0.3750          
##          Pos Pred Value : 0.5455          
##          Neg Pred Value : 0.5714          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3692          
##    Detection Prevalence : 0.6769          
##       Balanced Accuracy : 0.5511          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 4A AU features happiness model
set.seed(1973)
smile__tree_model_4A <- train(smile_type ~ AU06_r_mean + AU12_r_mean,
  method = "rpart",
  data = trn_smile,
  trControl = trainControl(
    method = "cv",
    number = 10
  )
)

# density plot of accuracy measurements
trellis.par.set(caretTheme())
densityplot(smile__tree_model_4A, pch = "|")

smile__tree_model_4A$resample
##     Accuracy       Kappa Resample
## 1  0.4545455 -0.09191176   Fold02
## 2  0.5454545  0.09506399   Fold01
## 3  0.6060606  0.22702703   Fold03
## 4  0.4848485 -0.02935780   Fold06
## 5  0.5000000  0.00000000   Fold05
## 6  0.4117647 -0.17647059   Fold04
## 7  0.5757576  0.14126394   Fold07
## 8  0.5294118  0.05882353   Fold10
## 9  0.4375000 -0.12500000   Fold09
## 10 0.4705882 -0.05882353   Fold08
smile__tree_model_4A$results
##           cp  Accuracy       Kappa AccuracySD    KappaSD
## 1 0.01969697 0.5015931  0.00406148 0.06213453 0.12621231
## 2 0.02828283 0.4866199 -0.02825439 0.04520997 0.08863008
## 3 0.10909091 0.4985684 -0.01151477 0.02486434 0.04647333
smile__tree_model_4A$coefnames
## [1] "AU06_r_mean" "AU12_r_mean"
varImp(smile__tree_model_4A)
## rpart variable importance
## 
##             Overall
## AU06_r_mean     100
## AU12_r_mean       0
# summary(smile__tree_model_4A$finalModel)
fancyRpartPlot(smile__tree_model_4A$finalModel,
  caption = "Model 4A: AU06 + AU12"
)

smile__tree_model_4A_pred <- predict(smile__tree_model_4A, tst_smile)
summary(smile__tree_model_4A_pred)
## spontaneous deliberate  
##          38         104
smile__tree_model_4A_confM <- confusionMatrix(
  smile__tree_model_4A_pred,
  tst_smile$smile_type
)
smile__tree_model_4A_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          20          18
##   deliberate           50          54
##                                           
##                Accuracy : 0.5211          
##                  95% CI : (0.4358, 0.6056)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.4008030       
##                                           
##                   Kappa : 0.0359          
##                                           
##  Mcnemar's Test P-Value : 0.0001704       
##                                           
##             Sensitivity : 0.2857          
##             Specificity : 0.7500          
##          Pos Pred Value : 0.5263          
##          Neg Pred Value : 0.5192          
##              Prevalence : 0.4930          
##          Detection Rate : 0.1408          
##    Detection Prevalence : 0.2676          
##       Balanced Accuracy : 0.5179          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_4A.1_pred <- predict(smile__tree_model_4A, tst_smile_boys)
summary(smile__tree_model_4A.1_pred)
## spontaneous deliberate  
##          23          54
smile__tree_model_4A.1_confM <- confusionMatrix(
  smile__tree_model_4A.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_4A.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          13          10
##   deliberate           24          30
##                                           
##                Accuracy : 0.5584          
##                  95% CI : (0.4407, 0.6716)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.28475         
##                                           
##                   Kappa : 0.1028          
##                                           
##  Mcnemar's Test P-Value : 0.02578         
##                                           
##             Sensitivity : 0.3514          
##             Specificity : 0.7500          
##          Pos Pred Value : 0.5652          
##          Neg Pred Value : 0.5556          
##              Prevalence : 0.4805          
##          Detection Rate : 0.1688          
##    Detection Prevalence : 0.2987          
##       Balanced Accuracy : 0.5507          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_4A.2_pred <- predict(smile__tree_model_4A, tst_smile_girls)
summary(smile__tree_model_4A.2_pred)
## spontaneous deliberate  
##          15          50
smile__tree_model_4A.2_confM <- confusionMatrix(
  smile__tree_model_4A.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_4A.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           7           8
##   deliberate           26          24
##                                           
##                Accuracy : 0.4769          
##                  95% CI : (0.3515, 0.6046)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.732416        
##                                           
##                   Kappa : -0.0376         
##                                           
##  Mcnemar's Test P-Value : 0.003551        
##                                           
##             Sensitivity : 0.2121          
##             Specificity : 0.7500          
##          Pos Pred Value : 0.4667          
##          Neg Pred Value : 0.4800          
##              Prevalence : 0.5077          
##          Detection Rate : 0.1077          
##    Detection Prevalence : 0.2308          
##       Balanced Accuracy : 0.4811          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 4B AU best model
set.seed(1973)
smile__tree_model_4B <- train(smile_type ~ AU01_r_mean + AU09_r_mean +
  AU10_r_mean + AU25_r_mean + AU45_r_mean,
method = "rpart",
data = trn_smile,
trControl = trainControl(
  method = "cv",
  number = 10
)
)

smile__tree_model_4B$results
##           cp  Accuracy      Kappa AccuracySD   KappaSD
## 1 0.03030303 0.5547126 0.11324964 0.07576006 0.1500753
## 2 0.04545455 0.5364305 0.07335263 0.07508962 0.1507522
## 3 0.22424242 0.5255849 0.04429576 0.04913641 0.0997257
smile__tree_model_4B$coefnames
## [1] "AU01_r_mean" "AU09_r_mean" "AU10_r_mean" "AU25_r_mean" "AU45_r_mean"
varImp(smile__tree_model_4B)
## rpart variable importance
## 
##             Overall
## AU25_r_mean  100.00
## AU45_r_mean   65.35
## AU01_r_mean   47.05
## AU10_r_mean   15.19
## AU09_r_mean    0.00
# summary(smile__tree_model_4$finalModel)
fancyRpartPlot(smile__tree_model_4B$finalModel)

smile__tree_model_4B_pred <- predict(smile__tree_model_4B, tst_smile)
summary(smile__tree_model_4B_pred)
## spontaneous deliberate  
##          89          53
smile__tree_model_4B_confM <- confusionMatrix(
  smile__tree_model_4B_pred,
  tst_smile$smile_type
)
smile__tree_model_4B_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          49          40
##   deliberate           21          32
##                                           
##                Accuracy : 0.5704          
##                  95% CI : (0.4847, 0.6531)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.07664         
##                                           
##                   Kappa : 0.1439          
##                                           
##  Mcnemar's Test P-Value : 0.02119         
##                                           
##             Sensitivity : 0.7000          
##             Specificity : 0.4444          
##          Pos Pred Value : 0.5506          
##          Neg Pred Value : 0.6038          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3451          
##    Detection Prevalence : 0.6268          
##       Balanced Accuracy : 0.5722          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_4B.1_pred <- predict(smile__tree_model_4B, tst_smile_boys)
summary(smile__tree_model_4B.1_pred)
## spontaneous deliberate  
##          41          36
smile__tree_model_4B.1_confM <- confusionMatrix(
  smile__tree_model_4B.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_4B.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          23          18
##   deliberate           14          22
##                                           
##                Accuracy : 0.5844          
##                  95% CI : (0.4664, 0.6957)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.1523          
##                                           
##                   Kappa : 0.1709          
##                                           
##  Mcnemar's Test P-Value : 0.5959          
##                                           
##             Sensitivity : 0.6216          
##             Specificity : 0.5500          
##          Pos Pred Value : 0.5610          
##          Neg Pred Value : 0.6111          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2987          
##    Detection Prevalence : 0.5325          
##       Balanced Accuracy : 0.5858          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_4B.2_pred <- predict(smile__tree_model_4B, tst_smile_girls)
summary(smile__tree_model_4B.2_pred)
## spontaneous deliberate  
##          48          17
smile__tree_model_4B.2_confM <- confusionMatrix(
  smile__tree_model_4B.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_4B.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          26          22
##   deliberate            7          10
##                                           
##                Accuracy : 0.5538          
##                  95% CI : (0.4253, 0.6773)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.26784         
##                                           
##                   Kappa : 0.1011          
##                                           
##  Mcnemar's Test P-Value : 0.00933         
##                                           
##             Sensitivity : 0.7879          
##             Specificity : 0.3125          
##          Pos Pred Value : 0.5417          
##          Neg Pred Value : 0.5882          
##              Prevalence : 0.5077          
##          Detection Rate : 0.4000          
##    Detection Prevalence : 0.7385          
##       Balanced Accuracy : 0.5502          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 4C AU happiness + blink
set.seed(1973)
smile__tree_model_4C <- train(smile_type ~ AU45_r_mean + AU06_r_mean +
  AU12_r_mean,
method = "rpart",
data = trn_smile,
trControl = trainControl(
  method = "cv",
  number = 10
)
)

smile__tree_model_4C$results
##           cp  Accuracy      Kappa AccuracySD    KappaSD
## 1 0.02424242 0.5797850 0.16016594 0.05522519 0.11234354
## 2 0.06060606 0.5464516 0.09717643 0.04388348 0.08896946
## 3 0.18787879 0.5223708 0.04901466 0.03672728 0.07788091
smile__tree_model_4C$coefnames
## [1] "AU45_r_mean" "AU06_r_mean" "AU12_r_mean"
varImp(smile__tree_model_4C)
## rpart variable importance
## 
##             Overall
## AU45_r_mean  100.00
## AU06_r_mean   31.92
## AU12_r_mean    0.00
# summary(smile__tree_model_4C$finalModel)
fancyRpartPlot(smile__tree_model_4C$finalModel)

smile__tree_model_4C_pred <- predict(smile__tree_model_4C, tst_smile)
summary(smile__tree_model_4C_pred)
## spontaneous deliberate  
##          85          57
smile__tree_model_4C_confM <- confusionMatrix(
  smile__tree_model_4C_pred,
  tst_smile$smile_type
)
smile__tree_model_4C_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          44          41
##   deliberate           26          31
##                                           
##                Accuracy : 0.5282          
##                  95% CI : (0.4427, 0.6124)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.3376          
##                                           
##                   Kappa : 0.059           
##                                           
##  Mcnemar's Test P-Value : 0.0872          
##                                           
##             Sensitivity : 0.6286          
##             Specificity : 0.4306          
##          Pos Pred Value : 0.5176          
##          Neg Pred Value : 0.5439          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3099          
##    Detection Prevalence : 0.5986          
##       Balanced Accuracy : 0.5296          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_4C.1_pred <- predict(smile__tree_model_4C, tst_smile_boys)
summary(smile__tree_model_4C.1_pred)
## spontaneous deliberate  
##          45          32
smile__tree_model_4C.1_confM <- confusionMatrix(
  smile__tree_model_4C.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_4C.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          23          22
##   deliberate           14          18
##                                           
##                Accuracy : 0.5325          
##                  95% CI : (0.4152, 0.6471)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.4552          
##                                           
##                   Kappa : 0.071           
##                                           
##  Mcnemar's Test P-Value : 0.2433          
##                                           
##             Sensitivity : 0.6216          
##             Specificity : 0.4500          
##          Pos Pred Value : 0.5111          
##          Neg Pred Value : 0.5625          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2987          
##    Detection Prevalence : 0.5844          
##       Balanced Accuracy : 0.5358          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_4C.2_pred <- predict(smile__tree_model_4C, tst_smile_girls)
summary(smile__tree_model_4C.2_pred)
## spontaneous deliberate  
##          40          25
smile__tree_model_4C.2_confM <- confusionMatrix(
  smile__tree_model_4C.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_4C.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          21          19
##   deliberate           12          13
##                                           
##                Accuracy : 0.5231          
##                  95% CI : (0.3954, 0.6485)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.4510          
##                                           
##                   Kappa : 0.0428          
##                                           
##  Mcnemar's Test P-Value : 0.2812          
##                                           
##             Sensitivity : 0.6364          
##             Specificity : 0.4062          
##          Pos Pred Value : 0.5250          
##          Neg Pred Value : 0.5200          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3231          
##    Detection Prevalence : 0.6154          
##       Balanced Accuracy : 0.5213          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 4D AU45
set.seed(1973)
smile__tree_model_4D <- train(smile_type ~ AU45_r_mean,
  method = "rpart",
  data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_4D$results
##           cp  Accuracy      Kappa AccuracySD    KappaSD
## 1 0.02121212 0.5617814 0.12519241 0.03886699 0.08002424
## 2 0.06060606 0.5464516 0.09717643 0.04388348 0.08896946
## 3 0.18787879 0.5223708 0.04901466 0.03672728 0.07788091
smile__tree_model_4D$coefnames
## [1] "AU45_r_mean"
# summary(smile__tree_model_4D$finalModel)

smile__tree_model_4D_pred <- predict(smile__tree_model_4D, tst_smile)
summary(smile__tree_model_4D_pred)
## spontaneous deliberate  
##          85          57
smile__tree_model_4D_confM <- confusionMatrix(
  smile__tree_model_4D_pred,
  tst_smile$smile_type
)
smile__tree_model_4D_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          44          41
##   deliberate           26          31
##                                           
##                Accuracy : 0.5282          
##                  95% CI : (0.4427, 0.6124)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.3376          
##                                           
##                   Kappa : 0.059           
##                                           
##  Mcnemar's Test P-Value : 0.0872          
##                                           
##             Sensitivity : 0.6286          
##             Specificity : 0.4306          
##          Pos Pred Value : 0.5176          
##          Neg Pred Value : 0.5439          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3099          
##    Detection Prevalence : 0.5986          
##       Balanced Accuracy : 0.5296          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_4D.1_pred <- predict(smile__tree_model_4D, tst_smile_boys)
summary(smile__tree_model_4D.1_pred)
## spontaneous deliberate  
##          45          32
smile__tree_model_4D.1_confM <- confusionMatrix(
  smile__tree_model_4D.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_4D.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          23          22
##   deliberate           14          18
##                                           
##                Accuracy : 0.5325          
##                  95% CI : (0.4152, 0.6471)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.4552          
##                                           
##                   Kappa : 0.071           
##                                           
##  Mcnemar's Test P-Value : 0.2433          
##                                           
##             Sensitivity : 0.6216          
##             Specificity : 0.4500          
##          Pos Pred Value : 0.5111          
##          Neg Pred Value : 0.5625          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2987          
##    Detection Prevalence : 0.5844          
##       Balanced Accuracy : 0.5358          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_4D.2_pred <- predict(smile__tree_model_4D, tst_smile_girls)
summary(smile__tree_model_4D.2_pred)
## spontaneous deliberate  
##          40          25
smile__tree_model_4D.2_confM <- confusionMatrix(
  smile__tree_model_4D.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_4D.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          21          19
##   deliberate           12          13
##                                           
##                Accuracy : 0.5231          
##                  95% CI : (0.3954, 0.6485)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.4510          
##                                           
##                   Kappa : 0.0428          
##                                           
##  Mcnemar's Test P-Value : 0.2812          
##                                           
##             Sensitivity : 0.6364          
##             Specificity : 0.4062          
##          Pos Pred Value : 0.5250          
##          Neg Pred Value : 0.5200          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3231          
##    Detection Prevalence : 0.6154          
##       Balanced Accuracy : 0.5213          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 4E AU12
set.seed(1973)
smile__tree_model_4E <- train(smile_type ~ AU12_r_mean,
  method = "rpart",
  data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_4E$results
##           cp  Accuracy        Kappa AccuracySD    KappaSD
## 1 0.01818182 0.5102496  0.020310865 0.08191055 0.16558148
## 2 0.03636364 0.5100713  0.019546074 0.05974664 0.11914570
## 3 0.06666667 0.4951872 -0.004623925 0.05086760 0.09953796
smile__tree_model_4E$coefnames
## [1] "AU12_r_mean"
# summary(smile__tree_model_4E$finalModel)

smile__tree_model_4E_pred <- predict(smile__tree_model_4E, tst_smile)
summary(smile__tree_model_4E_pred)
## spontaneous deliberate  
##          58          84
smile__tree_model_4E_confM <- confusionMatrix(
  smile__tree_model_4E_pred,
  tst_smile$smile_type
)
smile__tree_model_4E_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          29          29
##   deliberate           41          43
##                                           
##                Accuracy : 0.507           
##                  95% CI : (0.4219, 0.5919)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.5336          
##                                           
##                   Kappa : 0.0115          
##                                           
##  Mcnemar's Test P-Value : 0.1886          
##                                           
##             Sensitivity : 0.4143          
##             Specificity : 0.5972          
##          Pos Pred Value : 0.5000          
##          Neg Pred Value : 0.5119          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2042          
##    Detection Prevalence : 0.4085          
##       Balanced Accuracy : 0.5058          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_4E.1_pred <- predict(smile__tree_model_4E, tst_smile_boys)
summary(smile__tree_model_4E.1_pred)
## spontaneous deliberate  
##          21          56
smile__tree_model_4E.1_confM <- confusionMatrix(
  smile__tree_model_4E.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_4E.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          13           8
##   deliberate           24          32
##                                           
##                Accuracy : 0.5844          
##                  95% CI : (0.4664, 0.6957)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.15232         
##                                           
##                   Kappa : 0.1538          
##                                           
##  Mcnemar's Test P-Value : 0.00801         
##                                           
##             Sensitivity : 0.3514          
##             Specificity : 0.8000          
##          Pos Pred Value : 0.6190          
##          Neg Pred Value : 0.5714          
##              Prevalence : 0.4805          
##          Detection Rate : 0.1688          
##    Detection Prevalence : 0.2727          
##       Balanced Accuracy : 0.5757          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_4E.2_pred <- predict(smile__tree_model_4E, tst_smile_girls)
summary(smile__tree_model_4E.2_pred)
## spontaneous deliberate  
##          37          28
smile__tree_model_4E.2_confM <- confusionMatrix(
  smile__tree_model_4E.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_4E.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          16          21
##   deliberate           17          11
##                                           
##                Accuracy : 0.4154          
##                  95% CI : (0.2944, 0.5444)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.9468          
##                                           
##                   Kappa : -0.1717         
##                                           
##  Mcnemar's Test P-Value : 0.6265          
##                                           
##             Sensitivity : 0.4848          
##             Specificity : 0.3438          
##          Pos Pred Value : 0.4324          
##          Neg Pred Value : 0.3929          
##              Prevalence : 0.5077          
##          Detection Rate : 0.2462          
##    Detection Prevalence : 0.5692          
##       Balanced Accuracy : 0.4143          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 4F AU06
set.seed(1973)
smile__tree_model_4F <- train(smile_type ~ AU06_r_mean,
  method = "rpart",
  data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_4F$results
##           cp  Accuracy       Kappa AccuracySD    KappaSD
## 1 0.02020202 0.5135361  0.02820820 0.06572235 0.13344946
## 2 0.02828283 0.4896502 -0.02109638 0.05230700 0.10518620
## 3 0.10909091 0.4985684 -0.01151477 0.02486434 0.04647333
smile__tree_model_4F$coefnames
## [1] "AU06_r_mean"
# summary(smile__tree_model_4F$finalModel)

smile__tree_model_4F_pred <- predict(smile__tree_model_4F, tst_smile)
summary(smile__tree_model_4F_pred)
## spontaneous deliberate  
##          47          95
smile__tree_model_4F_confM <- confusionMatrix(
  smile__tree_model_4F_pred,
  tst_smile$smile_type
)
smile__tree_model_4F_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          22          25
##   deliberate           48          47
##                                           
##                Accuracy : 0.4859          
##                  95% CI : (0.4013, 0.5712)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.72157         
##                                           
##                   Kappa : -0.0331         
##                                           
##  Mcnemar's Test P-Value : 0.01003         
##                                           
##             Sensitivity : 0.3143          
##             Specificity : 0.6528          
##          Pos Pred Value : 0.4681          
##          Neg Pred Value : 0.4947          
##              Prevalence : 0.4930          
##          Detection Rate : 0.1549          
##    Detection Prevalence : 0.3310          
##       Balanced Accuracy : 0.4835          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_4F.1_pred <- predict(smile__tree_model_4F, tst_smile_boys)
summary(smile__tree_model_4F.1_pred)
## spontaneous deliberate  
##          26          51
smile__tree_model_4F.1_confM <- confusionMatrix(
  smile__tree_model_4F.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_4F.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          13          13
##   deliberate           24          27
##                                           
##                Accuracy : 0.5195          
##                  95% CI : (0.4026, 0.6348)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.5459          
##                                           
##                   Kappa : 0.0266          
##                                           
##  Mcnemar's Test P-Value : 0.1002          
##                                           
##             Sensitivity : 0.3514          
##             Specificity : 0.6750          
##          Pos Pred Value : 0.5000          
##          Neg Pred Value : 0.5294          
##              Prevalence : 0.4805          
##          Detection Rate : 0.1688          
##    Detection Prevalence : 0.3377          
##       Balanced Accuracy : 0.5132          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_4F.2_pred <- predict(smile__tree_model_4F, tst_smile_girls)
summary(smile__tree_model_4F.2_pred)
## spontaneous deliberate  
##          21          44
smile__tree_model_4F.2_confM <- confusionMatrix(
  smile__tree_model_4F.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_4F.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           9          12
##   deliberate           24          20
##                                           
##                Accuracy : 0.4462          
##                  95% CI : (0.3227, 0.5747)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.86792         
##                                           
##                   Kappa : -0.1017         
##                                           
##  Mcnemar's Test P-Value : 0.06675         
##                                           
##             Sensitivity : 0.2727          
##             Specificity : 0.6250          
##          Pos Pred Value : 0.4286          
##          Neg Pred Value : 0.4545          
##              Prevalence : 0.5077          
##          Detection Rate : 0.1385          
##    Detection Prevalence : 0.3231          
##       Balanced Accuracy : 0.4489          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 4G AU10
set.seed(1973)
smile__tree_model_4G <- train(smile_type ~ AU10_r_mean,
  method = "rpart",
  data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_4G$results
##           cp  Accuracy      Kappa AccuracySD    KappaSD
## 1 0.01212121 0.5520611 0.10499803 0.06372484 0.12732122
## 2 0.01414141 0.5253175 0.05036962 0.03849244 0.07670847
## 3 0.22424242 0.5437667 0.08478626 0.04730443 0.09468424
smile__tree_model_4G$coefnames
## [1] "AU10_r_mean"
# summary(smile__tree_model_4G$finalModel)

smile__tree_model_4G_pred <- predict(smile__tree_model_4G, tst_smile)
summary(smile__tree_model_4G_pred)
## spontaneous deliberate  
##          76          66
smile__tree_model_4G_confM <- confusionMatrix(
  smile__tree_model_4G_pred,
  tst_smile$smile_type
)
smile__tree_model_4G_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          38          38
##   deliberate           32          34
##                                           
##                Accuracy : 0.507           
##                  95% CI : (0.4219, 0.5919)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.5336          
##                                           
##                   Kappa : 0.0151          
##                                           
##  Mcnemar's Test P-Value : 0.5501          
##                                           
##             Sensitivity : 0.5429          
##             Specificity : 0.4722          
##          Pos Pred Value : 0.5000          
##          Neg Pred Value : 0.5152          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2676          
##    Detection Prevalence : 0.5352          
##       Balanced Accuracy : 0.5075          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_4G.1_pred <- predict(smile__tree_model_4G, tst_smile_boys)
summary(smile__tree_model_4G.1_pred)
## spontaneous deliberate  
##          32          45
smile__tree_model_4G.1_confM <- confusionMatrix(
  smile__tree_model_4G.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_4G.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          16          16
##   deliberate           21          24
##                                           
##                Accuracy : 0.5195          
##                  95% CI : (0.4026, 0.6348)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.5459          
##                                           
##                   Kappa : 0.0326          
##                                           
##  Mcnemar's Test P-Value : 0.5108          
##                                           
##             Sensitivity : 0.4324          
##             Specificity : 0.6000          
##          Pos Pred Value : 0.5000          
##          Neg Pred Value : 0.5333          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2078          
##    Detection Prevalence : 0.4156          
##       Balanced Accuracy : 0.5162          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_4G.2_pred <- predict(smile__tree_model_4G, tst_smile_girls)
summary(smile__tree_model_4G.2_pred)
## spontaneous deliberate  
##          44          21
smile__tree_model_4G.2_confM <- confusionMatrix(
  smile__tree_model_4G.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_4G.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          22          22
##   deliberate           11          10
##                                          
##                Accuracy : 0.4923         
##                  95% CI : (0.366, 0.6193)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.64516        
##                                          
##                   Kappa : -0.0209        
##                                          
##  Mcnemar's Test P-Value : 0.08172        
##                                          
##             Sensitivity : 0.6667         
##             Specificity : 0.3125         
##          Pos Pred Value : 0.5000         
##          Neg Pred Value : 0.4762         
##              Prevalence : 0.5077         
##          Detection Rate : 0.3385         
##    Detection Prevalence : 0.6769         
##       Balanced Accuracy : 0.4896         
##                                          
##        'Positive' Class : spontaneous    
## 
# model 4H AU01
set.seed(1973)
smile__tree_model_4H <- train(smile_type ~ AU01_r_mean,
  method = "rpart",
  data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_4H$results
##           cp  Accuracy      Kappa AccuracySD   KappaSD
## 1 0.01818182 0.5226437 0.04911567 0.09722360 0.1916064
## 2 0.03030303 0.5528743 0.10890407 0.09706592 0.1908838
## 3 0.14545455 0.5290775 0.06682929 0.09259357 0.1810430
smile__tree_model_4H$coefnames
## [1] "AU01_r_mean"
# summary(smile__tree_model_4H$finalModel)

smile__tree_model_4H_pred <- predict(smile__tree_model_4H, tst_smile)
summary(smile__tree_model_4H_pred)
## spontaneous deliberate  
##         107          35
smile__tree_model_4H_confM <- confusionMatrix(
  smile__tree_model_4H_pred,
  tst_smile$smile_type
)
smile__tree_model_4H_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          56          51
##   deliberate           14          21
##                                           
##                Accuracy : 0.5423          
##                  95% CI : (0.4567, 0.6261)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.2251          
##                                           
##                   Kappa : 0.091           
##                                           
##  Mcnemar's Test P-Value : 7.998e-06       
##                                           
##             Sensitivity : 0.8000          
##             Specificity : 0.2917          
##          Pos Pred Value : 0.5234          
##          Neg Pred Value : 0.6000          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3944          
##    Detection Prevalence : 0.7535          
##       Balanced Accuracy : 0.5458          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_4H.1_pred <- predict(smile__tree_model_4H, tst_smile_boys)
summary(smile__tree_model_4H.1_pred)
## spontaneous deliberate  
##          61          16
smile__tree_model_4H.1_confM <- confusionMatrix(
  smile__tree_model_4H.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_4H.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          32          29
##   deliberate            5          11
##                                           
##                Accuracy : 0.5584          
##                  95% CI : (0.4407, 0.6716)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.2847          
##                                           
##                   Kappa : 0.1365          
##                                           
##  Mcnemar's Test P-Value : 7.998e-05       
##                                           
##             Sensitivity : 0.8649          
##             Specificity : 0.2750          
##          Pos Pred Value : 0.5246          
##          Neg Pred Value : 0.6875          
##              Prevalence : 0.4805          
##          Detection Rate : 0.4156          
##    Detection Prevalence : 0.7922          
##       Balanced Accuracy : 0.5699          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_4H.2_pred <- predict(smile__tree_model_4H, tst_smile_girls)
summary(smile__tree_model_4H.2_pred)
## spontaneous deliberate  
##          46          19
smile__tree_model_4H.2_confM <- confusionMatrix(
  smile__tree_model_4H.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_4H.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          24          22
##   deliberate            9          10
##                                           
##                Accuracy : 0.5231          
##                  95% CI : (0.3954, 0.6485)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.45095         
##                                           
##                   Kappa : 0.04            
##                                           
##  Mcnemar's Test P-Value : 0.03114         
##                                           
##             Sensitivity : 0.7273          
##             Specificity : 0.3125          
##          Pos Pred Value : 0.5217          
##          Neg Pred Value : 0.5263          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3692          
##    Detection Prevalence : 0.7077          
##       Balanced Accuracy : 0.5199          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 4I AU25
set.seed(1973)
smile__tree_model_4I <- train(smile_type ~ AU25_r_mean,
  method = "rpart",
  data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_4I$results
##           cp  Accuracy      Kappa AccuracySD    KappaSD
## 1 0.03333333 0.5639149 0.13205234 0.06160107 0.12264971
## 2 0.06666667 0.5612411 0.12788597 0.03840889 0.06994947
## 3 0.14545455 0.5076705 0.02165391 0.01935801 0.04079529
smile__tree_model_4I$coefnames
## [1] "AU25_r_mean"
# summary(smile__tree_model_4I$finalModel)

smile__tree_model_4I_pred <- predict(smile__tree_model_4I, tst_smile)
summary(smile__tree_model_4I_pred)
## spontaneous deliberate  
##         122          20
smile__tree_model_4I_confM <- confusionMatrix(
  smile__tree_model_4I_pred,
  tst_smile$smile_type
)
smile__tree_model_4I_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          65          57
##   deliberate            5          15
##                                           
##                Accuracy : 0.5634          
##                  95% CI : (0.4777, 0.6464)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.1039          
##                                           
##                   Kappa : 0.1355          
##                                           
##  Mcnemar's Test P-Value : 9.356e-11       
##                                           
##             Sensitivity : 0.9286          
##             Specificity : 0.2083          
##          Pos Pred Value : 0.5328          
##          Neg Pred Value : 0.7500          
##              Prevalence : 0.4930          
##          Detection Rate : 0.4577          
##    Detection Prevalence : 0.8592          
##       Balanced Accuracy : 0.5685          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_4I.1_pred <- predict(smile__tree_model_4I, tst_smile_boys)
summary(smile__tree_model_4I.1_pred)
## spontaneous deliberate  
##          68           9
smile__tree_model_4I.1_confM <- confusionMatrix(
  smile__tree_model_4I.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_4I.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          35          33
##   deliberate            2           7
##                                           
##                Accuracy : 0.5455          
##                  95% CI : (0.4279, 0.6594)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.3667          
##                                           
##                   Kappa : 0.1173          
##                                           
##  Mcnemar's Test P-Value : 3.959e-07       
##                                           
##             Sensitivity : 0.9459          
##             Specificity : 0.1750          
##          Pos Pred Value : 0.5147          
##          Neg Pred Value : 0.7778          
##              Prevalence : 0.4805          
##          Detection Rate : 0.4545          
##    Detection Prevalence : 0.8831          
##       Balanced Accuracy : 0.5605          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_4I.2_pred <- predict(smile__tree_model_4I, tst_smile_girls)
summary(smile__tree_model_4I.2_pred)
## spontaneous deliberate  
##          54          11
smile__tree_model_4I.2_confM <- confusionMatrix(
  smile__tree_model_4I.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_4I.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          30          24
##   deliberate            3           8
##                                           
##                Accuracy : 0.5846          
##                  95% CI : (0.4556, 0.7056)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.1320123       
##                                           
##                   Kappa : 0.1607          
##                                           
##  Mcnemar's Test P-Value : 0.0001186       
##                                           
##             Sensitivity : 0.9091          
##             Specificity : 0.2500          
##          Pos Pred Value : 0.5556          
##          Neg Pred Value : 0.7273          
##              Prevalence : 0.5077          
##          Detection Rate : 0.4615          
##    Detection Prevalence : 0.8308          
##       Balanced Accuracy : 0.5795          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 4J AU09
set.seed(1973)
smile__tree_model_4J <- train(smile_type ~ AU09_r_mean,
  method = "rpart",
  data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_4J$results
##           cp  Accuracy      Kappa AccuracySD    KappaSD
## 1 0.01818182 0.5195131 0.04226591 0.06740442 0.13251259
## 2 0.02222222 0.5195131 0.04226591 0.06740442 0.13251259
## 3 0.16363636 0.5073028 0.01055068 0.02369084 0.04615194
smile__tree_model_4J$coefnames
## [1] "AU09_r_mean"
# summary(smile__tree_model_4J$finalModel)

smile__tree_model_4J_pred <- predict(smile__tree_model_4J, tst_smile)
summary(smile__tree_model_4J_pred)
## spontaneous deliberate  
##         109          33
smile__tree_model_4J_confM <- confusionMatrix(
  smile__tree_model_4J_pred,
  tst_smile$smile_type
)
smile__tree_model_4J_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          54          55
##   deliberate           16          17
##                                         
##                Accuracy : 0.5           
##                  95% CI : (0.415, 0.585)
##     No Information Rate : 0.507         
##     P-Value [Acc > NIR] : 0.5995        
##                                         
##                   Kappa : 0.0075        
##                                         
##  Mcnemar's Test P-Value : 6.49e-06      
##                                         
##             Sensitivity : 0.7714        
##             Specificity : 0.2361        
##          Pos Pred Value : 0.4954        
##          Neg Pred Value : 0.5152        
##              Prevalence : 0.4930        
##          Detection Rate : 0.3803        
##    Detection Prevalence : 0.7676        
##       Balanced Accuracy : 0.5038        
##                                         
##        'Positive' Class : spontaneous   
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_4J.1_pred <- predict(smile__tree_model_4J, tst_smile_boys)
summary(smile__tree_model_4J.1_pred)
## spontaneous deliberate  
##          57          20
smile__tree_model_4J.1_confM <- confusionMatrix(
  smile__tree_model_4J.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_4J.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          27          30
##   deliberate           10          10
##                                           
##                Accuracy : 0.4805          
##                  95% CI : (0.3652, 0.5974)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.787723        
##                                           
##                   Kappa : -0.0199         
##                                           
##  Mcnemar's Test P-Value : 0.002663        
##                                           
##             Sensitivity : 0.7297          
##             Specificity : 0.2500          
##          Pos Pred Value : 0.4737          
##          Neg Pred Value : 0.5000          
##              Prevalence : 0.4805          
##          Detection Rate : 0.3506          
##    Detection Prevalence : 0.7403          
##       Balanced Accuracy : 0.4899          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_4J.2_pred <- predict(smile__tree_model_4J, tst_smile_girls)
summary(smile__tree_model_4J.2_pred)
## spontaneous deliberate  
##          52          13
smile__tree_model_4J.2_confM <- confusionMatrix(
  smile__tree_model_4J.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_4J.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          27          25
##   deliberate            6           7
##                                           
##                Accuracy : 0.5231          
##                  95% CI : (0.3954, 0.6485)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.450951        
##                                           
##                   Kappa : 0.0373          
##                                           
##  Mcnemar's Test P-Value : 0.001225        
##                                           
##             Sensitivity : 0.8182          
##             Specificity : 0.2188          
##          Pos Pred Value : 0.5192          
##          Neg Pred Value : 0.5385          
##              Prevalence : 0.5077          
##          Detection Rate : 0.4154          
##    Detection Prevalence : 0.8000          
##       Balanced Accuracy : 0.5185          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 5 head pose features
set.seed(1973)
smile__tree_model_5 <-
  train(smile_type ~ pose_Rx_mean + pose_Ry_mean + pose_Rz_mean,
    method = "rpart", data = trn_smile,
    trControl = trainControl(method = "cv", number = 10)
  )

smile__tree_model_5$results
##           cp  Accuracy        Kappa AccuracySD    KappaSD
## 1 0.02575758 0.4929590 -0.018628892 0.06773807 0.13394796
## 2 0.02727273 0.5048964  0.005640949 0.07089130 0.14078111
## 3 0.10909091 0.5015096 -0.002110352 0.02310174 0.03990447
smile__tree_model_5$coefnames
## [1] "pose_Rx_mean" "pose_Ry_mean" "pose_Rz_mean"
varImp(smile__tree_model_5)
## rpart variable importance
## 
##              Overall
## pose_Rz_mean  100.00
## pose_Ry_mean   19.25
## pose_Rx_mean    0.00
# summary(smile__tree_model_5$finalModel)

smile__tree_model_5_pred <- predict(smile__tree_model_5, tst_smile)
summary(smile__tree_model_5_pred)
## spontaneous deliberate  
##          42         100
smile__tree_model_5_confM <- confusionMatrix(
  smile__tree_model_5_pred,
  tst_smile$smile_type
)
smile__tree_model_5_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          20          22
##   deliberate           50          50
##                                           
##                Accuracy : 0.493           
##                  95% CI : (0.4081, 0.5781)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.662667        
##                                           
##                   Kappa : -0.02           
##                                           
##  Mcnemar's Test P-Value : 0.001463        
##                                           
##             Sensitivity : 0.2857          
##             Specificity : 0.6944          
##          Pos Pred Value : 0.4762          
##          Neg Pred Value : 0.5000          
##              Prevalence : 0.4930          
##          Detection Rate : 0.1408          
##    Detection Prevalence : 0.2958          
##       Balanced Accuracy : 0.4901          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_5.1_pred <- predict(smile__tree_model_5, tst_smile_boys)
summary(smile__tree_model_5.1_pred)
## spontaneous deliberate  
##          19          58
smile__tree_model_5.1_confM <- confusionMatrix(
  smile__tree_model_5.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_5.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           8          11
##   deliberate           29          29
##                                           
##                Accuracy : 0.4805          
##                  95% CI : (0.3652, 0.5974)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.78772         
##                                           
##                   Kappa : -0.0599         
##                                           
##  Mcnemar's Test P-Value : 0.00719         
##                                           
##             Sensitivity : 0.2162          
##             Specificity : 0.7250          
##          Pos Pred Value : 0.4211          
##          Neg Pred Value : 0.5000          
##              Prevalence : 0.4805          
##          Detection Rate : 0.1039          
##    Detection Prevalence : 0.2468          
##       Balanced Accuracy : 0.4706          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_5.2_pred <- predict(smile__tree_model_5, tst_smile_girls)
summary(smile__tree_model_5.2_pred)
## spontaneous deliberate  
##          23          42
smile__tree_model_5.2_confM <- confusionMatrix(
  smile__tree_model_5.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_5.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          12          11
##   deliberate           21          21
##                                          
##                Accuracy : 0.5077         
##                  95% CI : (0.3807, 0.634)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.5495         
##                                          
##                   Kappa : 0.0198         
##                                          
##  Mcnemar's Test P-Value : 0.1116         
##                                          
##             Sensitivity : 0.3636         
##             Specificity : 0.6562         
##          Pos Pred Value : 0.5217         
##          Neg Pred Value : 0.5000         
##              Prevalence : 0.5077         
##          Detection Rate : 0.1846         
##    Detection Prevalence : 0.3538         
##       Balanced Accuracy : 0.5099         
##                                          
##        'Positive' Class : spontaneous    
## 
# model 5A gaze features
set.seed(1973)
smile__tree_model_5A <-
  train(smile_type ~ gaze_angle_x_mean + gaze_angle_y_mean,
    method = "rpart", data = trn_smile,
    trControl = trainControl(method = "cv", number = 10)
  )

smile__tree_model_5A$results
##           cp  Accuracy       Kappa AccuracySD   KappaSD
## 1 0.03939394 0.4440062 -0.10718904 0.08008631 0.1553984
## 2 0.04242424 0.4590686 -0.08001649 0.08664907 0.1694805
## 3 0.09090909 0.4810160 -0.04705882 0.05472730 0.1030112
smile__tree_model_5A$coefnames
## [1] "gaze_angle_x_mean" "gaze_angle_y_mean"
varImp(smile__tree_model_5A)
## rpart variable importance
## 
##                   Overall
## gaze_angle_x_mean     NaN
## gaze_angle_y_mean     NaN
# summary(smile__tree_model_5A$finalModel)

smile__tree_model_5A_pred <- predict(smile__tree_model_5A, tst_smile)
summary(smile__tree_model_5A_pred)
## spontaneous deliberate  
##           0         142
smile__tree_model_5A_confM <- confusionMatrix(
  smile__tree_model_5A_pred,
  tst_smile$smile_type
)
smile__tree_model_5A_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           0           0
##   deliberate           70          72
##                                           
##                Accuracy : 0.507           
##                  95% CI : (0.4219, 0.5919)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.5336          
##                                           
##                   Kappa : 0               
##                                           
##  Mcnemar's Test P-Value : <2e-16          
##                                           
##             Sensitivity : 0.000           
##             Specificity : 1.000           
##          Pos Pred Value :   NaN           
##          Neg Pred Value : 0.507           
##              Prevalence : 0.493           
##          Detection Rate : 0.000           
##    Detection Prevalence : 0.000           
##       Balanced Accuracy : 0.500           
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_5A.1_pred <- predict(smile__tree_model_5A, tst_smile_boys)
summary(smile__tree_model_5A.1_pred)
## spontaneous deliberate  
##           0          77
smile__tree_model_5A.1_confM <- confusionMatrix(
  smile__tree_model_5A.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_5A.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           0           0
##   deliberate           37          40
##                                           
##                Accuracy : 0.5195          
##                  95% CI : (0.4026, 0.6348)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.5459          
##                                           
##                   Kappa : 0               
##                                           
##  Mcnemar's Test P-Value : 3.252e-09       
##                                           
##             Sensitivity : 0.0000          
##             Specificity : 1.0000          
##          Pos Pred Value :    NaN          
##          Neg Pred Value : 0.5195          
##              Prevalence : 0.4805          
##          Detection Rate : 0.0000          
##    Detection Prevalence : 0.0000          
##       Balanced Accuracy : 0.5000          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_5A.2_pred <- predict(smile__tree_model_5A, tst_smile_girls)
summary(smile__tree_model_5A.2_pred)
## spontaneous deliberate  
##           0          65
smile__tree_model_5A.2_confM <- confusionMatrix(
  smile__tree_model_5A.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_5A.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           0           0
##   deliberate           33          32
##                                          
##                Accuracy : 0.4923         
##                  95% CI : (0.366, 0.6193)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.6452         
##                                          
##                   Kappa : 0              
##                                          
##  Mcnemar's Test P-Value : 2.54e-08       
##                                          
##             Sensitivity : 0.0000         
##             Specificity : 1.0000         
##          Pos Pred Value :    NaN         
##          Neg Pred Value : 0.4923         
##              Prevalence : 0.5077         
##          Detection Rate : 0.0000         
##    Detection Prevalence : 0.0000         
##       Balanced Accuracy : 0.5000         
##                                          
##        'Positive' Class : spontaneous    
## 
# model 5B headpose + gaze features
set.seed(1973)
smile__tree_model_5B <-
  train(smile_type ~ pose_Rx_mean + pose_Ry_mean + pose_Rz_mean +
    gaze_angle_x_mean + gaze_angle_y_mean,
  method = "rpart", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
  )

smile__tree_model_5B$results
##           cp  Accuracy        Kappa AccuracySD    KappaSD
## 1 0.01969697 0.4623719 -0.073073994 0.07260347 0.14825324
## 2 0.02575758 0.4686999 -0.064517461 0.07874648 0.16003545
## 3 0.10909091 0.5015096 -0.002110352 0.02310174 0.03990447
smile__tree_model_5B$coefnames
## [1] "pose_Rx_mean"      "pose_Ry_mean"      "pose_Rz_mean"     
## [4] "gaze_angle_x_mean" "gaze_angle_y_mean"
varImp(smile__tree_model_5B)
## rpart variable importance
## 
##                   Overall
## gaze_angle_y_mean     NaN
## gaze_angle_x_mean     NaN
## pose_Rx_mean          NaN
## pose_Ry_mean          NaN
## pose_Rz_mean          NaN
# summary(smile__tree_model_5B$finalModel)

smile__tree_model_5B_pred <- predict(smile__tree_model_5B, tst_smile)
summary(smile__tree_model_5B_pred)
## spontaneous deliberate  
##           0         142
smile__tree_model_5B_confM <- confusionMatrix(
  smile__tree_model_5B_pred,
  tst_smile$smile_type
)
smile__tree_model_5B_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           0           0
##   deliberate           70          72
##                                           
##                Accuracy : 0.507           
##                  95% CI : (0.4219, 0.5919)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.5336          
##                                           
##                   Kappa : 0               
##                                           
##  Mcnemar's Test P-Value : <2e-16          
##                                           
##             Sensitivity : 0.000           
##             Specificity : 1.000           
##          Pos Pred Value :   NaN           
##          Neg Pred Value : 0.507           
##              Prevalence : 0.493           
##          Detection Rate : 0.000           
##    Detection Prevalence : 0.000           
##       Balanced Accuracy : 0.500           
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_5B.1_pred <- predict(smile__tree_model_5B, tst_smile_boys)
summary(smile__tree_model_5B.1_pred)
## spontaneous deliberate  
##           0          77
smile__tree_model_5B.1_confM <- confusionMatrix(
  smile__tree_model_5B.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_5B.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           0           0
##   deliberate           37          40
##                                           
##                Accuracy : 0.5195          
##                  95% CI : (0.4026, 0.6348)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.5459          
##                                           
##                   Kappa : 0               
##                                           
##  Mcnemar's Test P-Value : 3.252e-09       
##                                           
##             Sensitivity : 0.0000          
##             Specificity : 1.0000          
##          Pos Pred Value :    NaN          
##          Neg Pred Value : 0.5195          
##              Prevalence : 0.4805          
##          Detection Rate : 0.0000          
##    Detection Prevalence : 0.0000          
##       Balanced Accuracy : 0.5000          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_5B.2_pred <- predict(smile__tree_model_5B, tst_smile_girls)
summary(smile__tree_model_5B.2_pred)
## spontaneous deliberate  
##           0          65
smile__tree_model_5B.2_confM <- confusionMatrix(
  smile__tree_model_5B.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_5B.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           0           0
##   deliberate           33          32
##                                          
##                Accuracy : 0.4923         
##                  95% CI : (0.366, 0.6193)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.6452         
##                                          
##                   Kappa : 0              
##                                          
##  Mcnemar's Test P-Value : 2.54e-08       
##                                          
##             Sensitivity : 0.0000         
##             Specificity : 1.0000         
##          Pos Pred Value :    NaN         
##          Neg Pred Value : 0.4923         
##              Prevalence : 0.5077         
##          Detection Rate : 0.0000         
##    Detection Prevalence : 0.0000         
##       Balanced Accuracy : 0.5000         
##                                          
##        'Positive' Class : spontaneous    
## 
# model 6 dynamics and movement
set.seed(1973)
smile__tree_model_6 <-
  train(smile_type ~ onset_mean + apex_mean + offset_mean + eye_mean + lip_mean,
    method = "rpart", data = trn_smile,
    trControl = trainControl(method = "cv", number = 10)
  )

smile__tree_model_6$results
##           cp  Accuracy       Kappa AccuracySD    KappaSD
## 1 0.04242424 0.5492090  0.09642256 0.09355662 0.18550882
## 2 0.06666667 0.5314728  0.06480625 0.09078317 0.17739898
## 3 0.16363636 0.4868093 -0.03388104 0.03960046 0.07404332
smile__tree_model_6$coefnames
## [1] "onset_mean"  "apex_mean"   "offset_mean" "eye_mean"    "lip_mean"
varImp(smile__tree_model_6)
## rpart variable importance
## 
##             Overall
## eye_mean     100.00
## offset_mean   77.33
## onset_mean    43.18
## apex_mean     19.36
## lip_mean       0.00
# summary(smile__tree_model_6$finalModel)
fancyRpartPlot(smile__tree_model_6$finalModel)

smile__tree_model_6_pred <- predict(smile__tree_model_6, tst_smile)
summary(smile__tree_model_6_pred)
## spontaneous deliberate  
##          88          54
smile__tree_model_6_confM <- confusionMatrix(
  smile__tree_model_6_pred,
  tst_smile$smile_type
)
smile__tree_model_6_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          45          43
##   deliberate           25          29
##                                           
##                Accuracy : 0.5211          
##                  95% CI : (0.4358, 0.6056)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.40080         
##                                           
##                   Kappa : 0.0455          
##                                           
##  Mcnemar's Test P-Value : 0.03925         
##                                           
##             Sensitivity : 0.6429          
##             Specificity : 0.4028          
##          Pos Pred Value : 0.5114          
##          Neg Pred Value : 0.5370          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3169          
##    Detection Prevalence : 0.6197          
##       Balanced Accuracy : 0.5228          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_6.1_pred <- predict(smile__tree_model_6, tst_smile_boys)
summary(smile__tree_model_6.1_pred)
## spontaneous deliberate  
##          52          25
smile__tree_model_6.1_confM <- confusionMatrix(
  smile__tree_model_6.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_6.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          26          26
##   deliberate           11          14
##                                           
##                Accuracy : 0.5195          
##                  95% CI : (0.4026, 0.6348)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.54593         
##                                           
##                   Kappa : 0.0519          
##                                           
##  Mcnemar's Test P-Value : 0.02136         
##                                           
##             Sensitivity : 0.7027          
##             Specificity : 0.3500          
##          Pos Pred Value : 0.5000          
##          Neg Pred Value : 0.5600          
##              Prevalence : 0.4805          
##          Detection Rate : 0.3377          
##    Detection Prevalence : 0.6753          
##       Balanced Accuracy : 0.5264          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_6.2_pred <- predict(smile__tree_model_6, tst_smile_girls)
summary(smile__tree_model_6.2_pred)
## spontaneous deliberate  
##          36          29
smile__tree_model_6.2_confM <- confusionMatrix(
  smile__tree_model_6.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_6.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          19          17
##   deliberate           14          15
##                                           
##                Accuracy : 0.5231          
##                  95% CI : (0.3954, 0.6485)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.4510          
##                                           
##                   Kappa : 0.0446          
##                                           
##  Mcnemar's Test P-Value : 0.7194          
##                                           
##             Sensitivity : 0.5758          
##             Specificity : 0.4688          
##          Pos Pred Value : 0.5278          
##          Neg Pred Value : 0.5172          
##              Prevalence : 0.5077          
##          Detection Rate : 0.2923          
##    Detection Prevalence : 0.5538          
##       Balanced Accuracy : 0.5223          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 6A dynamics and eye movement
set.seed(1973)
smile__tree_model_6A <-
  train(smile_type ~ onset_mean + apex_mean + offset_mean + eye_mean,
    method = "rpart", data = trn_smile,
    trControl = trainControl(method = "cv", number = 10)
  )

smile__tree_model_6A$results
##           cp  Accuracy       Kappa AccuracySD    KappaSD
## 1 0.04242424 0.5522393  0.10505764 0.08946029 0.17418506
## 2 0.06666667 0.5314728  0.06480625 0.09078317 0.17739898
## 3 0.16363636 0.4868093 -0.03388104 0.03960046 0.07404332
smile__tree_model_6A$coefnames
## [1] "onset_mean"  "apex_mean"   "offset_mean" "eye_mean"
varImp(smile__tree_model_6A)
## rpart variable importance
## 
##             Overall
## eye_mean     100.00
## offset_mean   71.88
## onset_mean    29.55
## apex_mean      0.00
# summary(smile__tree_model_6A$finalModel)
fancyRpartPlot(smile__tree_model_6A$finalModel)

smile__tree_model_6A_pred <- predict(smile__tree_model_6A, tst_smile)
summary(smile__tree_model_6A_pred)
## spontaneous deliberate  
##          88          54
smile__tree_model_6A_confM <- confusionMatrix(
  smile__tree_model_6A_pred,
  tst_smile$smile_type
)
smile__tree_model_6A_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          45          43
##   deliberate           25          29
##                                           
##                Accuracy : 0.5211          
##                  95% CI : (0.4358, 0.6056)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.40080         
##                                           
##                   Kappa : 0.0455          
##                                           
##  Mcnemar's Test P-Value : 0.03925         
##                                           
##             Sensitivity : 0.6429          
##             Specificity : 0.4028          
##          Pos Pred Value : 0.5114          
##          Neg Pred Value : 0.5370          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3169          
##    Detection Prevalence : 0.6197          
##       Balanced Accuracy : 0.5228          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_6A.1_pred <- predict(smile__tree_model_6A, tst_smile_boys)
summary(smile__tree_model_6A.1_pred)
## spontaneous deliberate  
##          52          25
smile__tree_model_6A.1_confM <- confusionMatrix(
  smile__tree_model_6A.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_6A.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          26          26
##   deliberate           11          14
##                                           
##                Accuracy : 0.5195          
##                  95% CI : (0.4026, 0.6348)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.54593         
##                                           
##                   Kappa : 0.0519          
##                                           
##  Mcnemar's Test P-Value : 0.02136         
##                                           
##             Sensitivity : 0.7027          
##             Specificity : 0.3500          
##          Pos Pred Value : 0.5000          
##          Neg Pred Value : 0.5600          
##              Prevalence : 0.4805          
##          Detection Rate : 0.3377          
##    Detection Prevalence : 0.6753          
##       Balanced Accuracy : 0.5264          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_6A.2_pred <- predict(smile__tree_model_6A, tst_smile_girls)
summary(smile__tree_model_6A.2_pred)
## spontaneous deliberate  
##          36          29
smile__tree_model_6A.2_confM <- confusionMatrix(
  smile__tree_model_6A.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_6A.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          19          17
##   deliberate           14          15
##                                           
##                Accuracy : 0.5231          
##                  95% CI : (0.3954, 0.6485)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.4510          
##                                           
##                   Kappa : 0.0446          
##                                           
##  Mcnemar's Test P-Value : 0.7194          
##                                           
##             Sensitivity : 0.5758          
##             Specificity : 0.4688          
##          Pos Pred Value : 0.5278          
##          Neg Pred Value : 0.5172          
##              Prevalence : 0.5077          
##          Detection Rate : 0.2923          
##    Detection Prevalence : 0.5538          
##       Balanced Accuracy : 0.5223          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 6B dynamics and lip movement
set.seed(1973)
smile__tree_model_6B <-
  train(smile_type ~ onset_mean + apex_mean + offset_mean + lip_mean,
    method = "rpart", data = trn_smile,
    trControl = trainControl(method = "cv", number = 10)
  )

smile__tree_model_6B$results
##           cp  Accuracy      Kappa AccuracySD   KappaSD
## 1 0.04242424 0.5341466 0.06676405 0.08133394 0.1623784
## 2 0.06666667 0.5102718 0.02342038 0.08905266 0.1730390
## 3 0.07878788 0.5106283 0.02562619 0.06235534 0.1200097
smile__tree_model_6B$coefnames
## [1] "onset_mean"  "apex_mean"   "offset_mean" "lip_mean"
varImp(smile__tree_model_6B)
## rpart variable importance
## 
##             Overall
## apex_mean    100.00
## offset_mean   67.01
## lip_mean      64.83
## onset_mean     0.00
# summary(smile__tree_model_6B$finalModel)
fancyRpartPlot(smile__tree_model_6B$finalModel)

smile__tree_model_6B_pred <- predict(smile__tree_model_6B, tst_smile)
summary(smile__tree_model_6B_pred)
## spontaneous deliberate  
##          51          91
smile__tree_model_6B_confM <- confusionMatrix(
  smile__tree_model_6B_pred,
  tst_smile$smile_type
)
smile__tree_model_6B_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          36          15
##   deliberate           34          57
##                                           
##                Accuracy : 0.6549          
##                  95% CI : (0.5706, 0.7326)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.0002621       
##                                           
##                   Kappa : 0.3071          
##                                           
##  Mcnemar's Test P-Value : 0.0101280       
##                                           
##             Sensitivity : 0.5143          
##             Specificity : 0.7917          
##          Pos Pred Value : 0.7059          
##          Neg Pred Value : 0.6264          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2535          
##    Detection Prevalence : 0.3592          
##       Balanced Accuracy : 0.6530          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_6B.1_pred <- predict(smile__tree_model_6B, tst_smile_boys)
# summary(smile__tree_model_6B.1_pred)
smile__tree_model_6B.1_confM <- confusionMatrix(
  smile__tree_model_6B.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_6B.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          20          10
##   deliberate           17          30
##                                           
##                Accuracy : 0.6494          
##                  95% CI : (0.5322, 0.7547)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.01457         
##                                           
##                   Kappa : 0.2926          
##                                           
##  Mcnemar's Test P-Value : 0.24821         
##                                           
##             Sensitivity : 0.5405          
##             Specificity : 0.7500          
##          Pos Pred Value : 0.6667          
##          Neg Pred Value : 0.6383          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2597          
##    Detection Prevalence : 0.3896          
##       Balanced Accuracy : 0.6453          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_6B.2_pred <- predict(smile__tree_model_6B, tst_smile_girls)
summary(smile__tree_model_6B.2_pred)
## spontaneous deliberate  
##          21          44
smile__tree_model_6B.2_confM <- confusionMatrix(
  smile__tree_model_6B.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_6B.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          16           5
##   deliberate           17          27
##                                           
##                Accuracy : 0.6615          
##                  95% CI : (0.5335, 0.7743)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.008794        
##                                           
##                   Kappa : 0.3267          
##                                           
##  Mcnemar's Test P-Value : 0.019016        
##                                           
##             Sensitivity : 0.4848          
##             Specificity : 0.8438          
##          Pos Pred Value : 0.7619          
##          Neg Pred Value : 0.6136          
##              Prevalence : 0.5077          
##          Detection Rate : 0.2462          
##    Detection Prevalence : 0.3231          
##       Balanced Accuracy : 0.6643          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 6C onset and movement
set.seed(1973)
smile__tree_model_6C <- train(smile_type ~ onset_mean + eye_mean + lip_mean,
  method = "rpart", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_6C$results
##           cp  Accuracy       Kappa AccuracySD    KappaSD
## 1 0.02424242 0.5678420  0.13387329 0.07670856 0.15409631
## 2 0.06666667 0.5863024  0.16881293 0.10339900 0.20811509
## 3 0.16363636 0.4868093 -0.03388104 0.03960046 0.07404332
smile__tree_model_6C$coefnames
## [1] "onset_mean" "eye_mean"   "lip_mean"
varImp(smile__tree_model_6C)
## rpart variable importance
## 
##            Overall
## eye_mean     100.0
## onset_mean    18.8
## lip_mean       0.0
# summary(smile__tree_model_6C$finalModel)
fancyRpartPlot(smile__tree_model_6C$finalModel)

smile__tree_model_6C_pred <- predict(smile__tree_model_6C, tst_smile)
summary(smile__tree_model_6C_pred)
## spontaneous deliberate  
##          41         101
smile__tree_model_6C_confM <- confusionMatrix(
  smile__tree_model_6C_pred,
  tst_smile$smile_type
)
smile__tree_model_6C_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          25          16
##   deliberate           45          56
##                                           
##                Accuracy : 0.5704          
##                  95% CI : (0.4847, 0.6531)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.076642        
##                                           
##                   Kappa : 0.1357          
##                                           
##  Mcnemar's Test P-Value : 0.000337        
##                                           
##             Sensitivity : 0.3571          
##             Specificity : 0.7778          
##          Pos Pred Value : 0.6098          
##          Neg Pred Value : 0.5545          
##              Prevalence : 0.4930          
##          Detection Rate : 0.1761          
##    Detection Prevalence : 0.2887          
##       Balanced Accuracy : 0.5675          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_6C.1_pred <- predict(smile__tree_model_6C, tst_smile_boys)
summary(smile__tree_model_6C.1_pred)
## spontaneous deliberate  
##          22          55
smile__tree_model_6C.1_confM <- confusionMatrix(
  smile__tree_model_6C.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_6C.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          13           9
##   deliberate           24          31
##                                           
##                Accuracy : 0.5714          
##                  95% CI : (0.4535, 0.6837)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.21259         
##                                           
##                   Kappa : 0.1283          
##                                           
##  Mcnemar's Test P-Value : 0.01481         
##                                           
##             Sensitivity : 0.3514          
##             Specificity : 0.7750          
##          Pos Pred Value : 0.5909          
##          Neg Pred Value : 0.5636          
##              Prevalence : 0.4805          
##          Detection Rate : 0.1688          
##    Detection Prevalence : 0.2857          
##       Balanced Accuracy : 0.5632          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_6C.2_pred <- predict(smile__tree_model_6C, tst_smile_girls)
summary(smile__tree_model_6C.2_pred)
## spontaneous deliberate  
##          19          46
smile__tree_model_6C.2_confM <- confusionMatrix(
  smile__tree_model_6C.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_6C.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          12           7
##   deliberate           21          25
##                                           
##                Accuracy : 0.5692          
##                  95% CI : (0.4404, 0.6915)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.19273         
##                                           
##                   Kappa : 0.1439          
##                                           
##  Mcnemar's Test P-Value : 0.01402         
##                                           
##             Sensitivity : 0.3636          
##             Specificity : 0.7812          
##          Pos Pred Value : 0.6316          
##          Neg Pred Value : 0.5435          
##              Prevalence : 0.5077          
##          Detection Rate : 0.1846          
##    Detection Prevalence : 0.2923          
##       Balanced Accuracy : 0.5724          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 6D onset + eye
set.seed(1973)
smile__tree_model_6D <- train(smile_type ~ onset_mean + eye_mean,
  method = "rpart", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_6D$results
##           cp  Accuracy       Kappa AccuracySD    KappaSD
## 1 0.03030303 0.5830882  0.16410842 0.07002286 0.13877600
## 2 0.06666667 0.5863024  0.16881293 0.10339900 0.20811509
## 3 0.16363636 0.4868093 -0.03388104 0.03960046 0.07404332
smile__tree_model_6D$coefnames
## [1] "onset_mean" "eye_mean"
varImp(smile__tree_model_6D)
## rpart variable importance
## 
##            Overall
## eye_mean       100
## onset_mean       0
# summary(smile__tree_model_6D$finalModel)
fancyRpartPlot(smile__tree_model_6D$finalModel)

smile__tree_model_6D_pred <- predict(smile__tree_model_6D, tst_smile)
summary(smile__tree_model_6D_pred)
## spontaneous deliberate  
##          41         101
smile__tree_model_6D_confM <- confusionMatrix(
  smile__tree_model_6D_pred,
  tst_smile$smile_type
)
smile__tree_model_6D_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          25          16
##   deliberate           45          56
##                                           
##                Accuracy : 0.5704          
##                  95% CI : (0.4847, 0.6531)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.076642        
##                                           
##                   Kappa : 0.1357          
##                                           
##  Mcnemar's Test P-Value : 0.000337        
##                                           
##             Sensitivity : 0.3571          
##             Specificity : 0.7778          
##          Pos Pred Value : 0.6098          
##          Neg Pred Value : 0.5545          
##              Prevalence : 0.4930          
##          Detection Rate : 0.1761          
##    Detection Prevalence : 0.2887          
##       Balanced Accuracy : 0.5675          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_6D.1_pred <- predict(smile__tree_model_6D, tst_smile_boys)
summary(smile__tree_model_6D.1_pred)
## spontaneous deliberate  
##          22          55
smile__tree_model_6D.1_confM <- confusionMatrix(
  smile__tree_model_6D.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_6D.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          13           9
##   deliberate           24          31
##                                           
##                Accuracy : 0.5714          
##                  95% CI : (0.4535, 0.6837)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.21259         
##                                           
##                   Kappa : 0.1283          
##                                           
##  Mcnemar's Test P-Value : 0.01481         
##                                           
##             Sensitivity : 0.3514          
##             Specificity : 0.7750          
##          Pos Pred Value : 0.5909          
##          Neg Pred Value : 0.5636          
##              Prevalence : 0.4805          
##          Detection Rate : 0.1688          
##    Detection Prevalence : 0.2857          
##       Balanced Accuracy : 0.5632          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_6D.2_pred <- predict(smile__tree_model_6D, tst_smile_girls)
summary(smile__tree_model_6D.2_pred)
## spontaneous deliberate  
##          19          46
smile__tree_model_6D.2_confM <- confusionMatrix(
  smile__tree_model_6D.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_6D.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          12           7
##   deliberate           21          25
##                                           
##                Accuracy : 0.5692          
##                  95% CI : (0.4404, 0.6915)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.19273         
##                                           
##                   Kappa : 0.1439          
##                                           
##  Mcnemar's Test P-Value : 0.01402         
##                                           
##             Sensitivity : 0.3636          
##             Specificity : 0.7812          
##          Pos Pred Value : 0.6316          
##          Neg Pred Value : 0.5435          
##              Prevalence : 0.5077          
##          Detection Rate : 0.1846          
##    Detection Prevalence : 0.2923          
##       Balanced Accuracy : 0.5724          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 6E onset + lip
set.seed(1973)
smile__tree_model_6E <- train(smile_type ~ onset_mean + lip_mean,
  method = "rpart", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_6E$results
##           cp  Accuracy       Kappa AccuracySD   KappaSD
## 1 0.02121212 0.5669285  0.13279284 0.05096836 0.1021507
## 2 0.02424242 0.5670232  0.13415123 0.04546484 0.0904795
## 3 0.05909091 0.4897504 -0.02427537 0.05640185 0.1111774
smile__tree_model_6E$coefnames
## [1] "onset_mean" "lip_mean"
varImp(smile__tree_model_6E)
## rpart variable importance
## 
##            Overall
## lip_mean       100
## onset_mean       0
# summary(smile__tree_model_6E$finalModel)
fancyRpartPlot(smile__tree_model_6E$finalModel)

smile__tree_model_6E_pred <- predict(smile__tree_model_6E, tst_smile)
summary(smile__tree_model_6E_pred)
## spontaneous deliberate  
##          68          74
smile__tree_model_6E_confM <- confusionMatrix(
  smile__tree_model_6E_pred,
  tst_smile$smile_type
)
smile__tree_model_6E_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          35          33
##   deliberate           35          39
##                                           
##                Accuracy : 0.5211          
##                  95% CI : (0.4358, 0.6056)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.4008          
##                                           
##                   Kappa : 0.0417          
##                                           
##  Mcnemar's Test P-Value : 0.9035          
##                                           
##             Sensitivity : 0.5000          
##             Specificity : 0.5417          
##          Pos Pred Value : 0.5147          
##          Neg Pred Value : 0.5270          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2465          
##    Detection Prevalence : 0.4789          
##       Balanced Accuracy : 0.5208          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_6E.1_pred <- predict(smile__tree_model_6E, tst_smile_boys)
summary(smile__tree_model_6E.1_pred)
## spontaneous deliberate  
##          34          43
smile__tree_model_6E.1_confM <- confusionMatrix(
  smile__tree_model_6E.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_6E.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          15          19
##   deliberate           22          21
##                                           
##                Accuracy : 0.4675          
##                  95% CI : (0.3529, 0.5848)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.8476          
##                                           
##                   Kappa : -0.0698         
##                                           
##  Mcnemar's Test P-Value : 0.7548          
##                                           
##             Sensitivity : 0.4054          
##             Specificity : 0.5250          
##          Pos Pred Value : 0.4412          
##          Neg Pred Value : 0.4884          
##              Prevalence : 0.4805          
##          Detection Rate : 0.1948          
##    Detection Prevalence : 0.4416          
##       Balanced Accuracy : 0.4652          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_6E.2_pred <- predict(smile__tree_model_6E, tst_smile_girls)
summary(smile__tree_model_6E.2_pred)
## spontaneous deliberate  
##          34          31
smile__tree_model_6E.2_confM <- confusionMatrix(
  smile__tree_model_6E.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_6E.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          20          14
##   deliberate           13          18
##                                           
##                Accuracy : 0.5846          
##                  95% CI : (0.4556, 0.7056)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.132           
##                                           
##                   Kappa : 0.1686          
##                                           
##  Mcnemar's Test P-Value : 1.000           
##                                           
##             Sensitivity : 0.6061          
##             Specificity : 0.5625          
##          Pos Pred Value : 0.5882          
##          Neg Pred Value : 0.5806          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3077          
##    Detection Prevalence : 0.5231          
##       Balanced Accuracy : 0.5843          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 6F apex and movement
set.seed(1973)
smile__tree_model_6F <- train(smile_type ~ apex_mean + eye_mean + lip_mean,
  method = "rpart", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_6F$results
##           cp  Accuracy       Kappa AccuracySD    KappaSD
## 1 0.04242424 0.5920065  0.18186252 0.09150065 0.18186377
## 2 0.06666667 0.5892435  0.17469528 0.10479850 0.21101409
## 3 0.16363636 0.4868093 -0.03388104 0.03960046 0.07404332
smile__tree_model_6F$coefnames
## [1] "apex_mean" "eye_mean"  "lip_mean"
varImp(smile__tree_model_6F)
## rpart variable importance
## 
##           Overall
## eye_mean   100.00
## apex_mean   19.36
## lip_mean     0.00
# summary(smile__tree_model_6F$finalModel)
fancyRpartPlot(smile__tree_model_6F$finalModel,
  caption = "model 6F: Decision Tree - apex, eye, lip"
)

smile__tree_model_6F_pred <- predict(smile__tree_model_6F, tst_smile)
summary(smile__tree_model_6F_pred)
## spontaneous deliberate  
##          88          54
smile__tree_model_6F_confM <- confusionMatrix(
  smile__tree_model_6F_pred,
  tst_smile$smile_type
)
smile__tree_model_6F_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          45          43
##   deliberate           25          29
##                                           
##                Accuracy : 0.5211          
##                  95% CI : (0.4358, 0.6056)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.40080         
##                                           
##                   Kappa : 0.0455          
##                                           
##  Mcnemar's Test P-Value : 0.03925         
##                                           
##             Sensitivity : 0.6429          
##             Specificity : 0.4028          
##          Pos Pred Value : 0.5114          
##          Neg Pred Value : 0.5370          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3169          
##    Detection Prevalence : 0.6197          
##       Balanced Accuracy : 0.5228          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_6F.1_pred <- predict(smile__tree_model_6F, tst_smile_boys)
summary(smile__tree_model_6F.1_pred)
## spontaneous deliberate  
##          52          25
smile__tree_model_6F.1_confM <- confusionMatrix(
  smile__tree_model_6F.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_6F.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          26          26
##   deliberate           11          14
##                                           
##                Accuracy : 0.5195          
##                  95% CI : (0.4026, 0.6348)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.54593         
##                                           
##                   Kappa : 0.0519          
##                                           
##  Mcnemar's Test P-Value : 0.02136         
##                                           
##             Sensitivity : 0.7027          
##             Specificity : 0.3500          
##          Pos Pred Value : 0.5000          
##          Neg Pred Value : 0.5600          
##              Prevalence : 0.4805          
##          Detection Rate : 0.3377          
##    Detection Prevalence : 0.6753          
##       Balanced Accuracy : 0.5264          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_6F.2_pred <- predict(smile__tree_model_6F, tst_smile_girls)
summary(smile__tree_model_6F.2_pred)
## spontaneous deliberate  
##          36          29
smile__tree_model_6F.2_confM <- confusionMatrix(
  smile__tree_model_6F.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_6F.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          19          17
##   deliberate           14          15
##                                           
##                Accuracy : 0.5231          
##                  95% CI : (0.3954, 0.6485)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.4510          
##                                           
##                   Kappa : 0.0446          
##                                           
##  Mcnemar's Test P-Value : 0.7194          
##                                           
##             Sensitivity : 0.5758          
##             Specificity : 0.4688          
##          Pos Pred Value : 0.5278          
##          Neg Pred Value : 0.5172          
##              Prevalence : 0.5077          
##          Detection Rate : 0.2923          
##    Detection Prevalence : 0.5538          
##       Balanced Accuracy : 0.5223          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 6G apex + eye
set.seed(1973)
smile__tree_model_6G <- train(smile_type ~ apex_mean + eye_mean,
  method = "rpart", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_6G$results
##           cp  Accuracy       Kappa AccuracySD    KappaSD
## 1 0.04242424 0.5920065  0.18186252 0.09150065 0.18186377
## 2 0.06666667 0.5892435  0.17469528 0.10479850 0.21101409
## 3 0.16363636 0.4868093 -0.03388104 0.03960046 0.07404332
smile__tree_model_6G$coefnames
## [1] "apex_mean" "eye_mean"
varImp(smile__tree_model_6G)
## rpart variable importance
## 
##           Overall
## eye_mean      100
## apex_mean       0
# summary(smile__tree_model_6G$finalModel)
fancyRpartPlot(smile__tree_model_6G$finalModel)

smile__tree_model_6G_pred <- predict(smile__tree_model_6G, tst_smile)
summary(smile__tree_model_6G_pred)
## spontaneous deliberate  
##          88          54
smile__tree_model_6G_confM <- confusionMatrix(
  smile__tree_model_6G_pred,
  tst_smile$smile_type
)
smile__tree_model_6G_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          45          43
##   deliberate           25          29
##                                           
##                Accuracy : 0.5211          
##                  95% CI : (0.4358, 0.6056)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.40080         
##                                           
##                   Kappa : 0.0455          
##                                           
##  Mcnemar's Test P-Value : 0.03925         
##                                           
##             Sensitivity : 0.6429          
##             Specificity : 0.4028          
##          Pos Pred Value : 0.5114          
##          Neg Pred Value : 0.5370          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3169          
##    Detection Prevalence : 0.6197          
##       Balanced Accuracy : 0.5228          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_6G.1_pred <- predict(smile__tree_model_6G, tst_smile_boys)
summary(smile__tree_model_6G.1_pred)
## spontaneous deliberate  
##          52          25
smile__tree_model_6G.1_confM <- confusionMatrix(
  smile__tree_model_6G.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_6G.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          26          26
##   deliberate           11          14
##                                           
##                Accuracy : 0.5195          
##                  95% CI : (0.4026, 0.6348)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.54593         
##                                           
##                   Kappa : 0.0519          
##                                           
##  Mcnemar's Test P-Value : 0.02136         
##                                           
##             Sensitivity : 0.7027          
##             Specificity : 0.3500          
##          Pos Pred Value : 0.5000          
##          Neg Pred Value : 0.5600          
##              Prevalence : 0.4805          
##          Detection Rate : 0.3377          
##    Detection Prevalence : 0.6753          
##       Balanced Accuracy : 0.5264          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_6G.2_pred <- predict(smile__tree_model_6G, tst_smile_girls)
summary(smile__tree_model_6G.2_pred)
## spontaneous deliberate  
##          36          29
smile__tree_model_6G.2_confM <- confusionMatrix(
  smile__tree_model_6G.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_6G.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          19          17
##   deliberate           14          15
##                                           
##                Accuracy : 0.5231          
##                  95% CI : (0.3954, 0.6485)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.4510          
##                                           
##                   Kappa : 0.0446          
##                                           
##  Mcnemar's Test P-Value : 0.7194          
##                                           
##             Sensitivity : 0.5758          
##             Specificity : 0.4688          
##          Pos Pred Value : 0.5278          
##          Neg Pred Value : 0.5172          
##              Prevalence : 0.5077          
##          Detection Rate : 0.2923          
##    Detection Prevalence : 0.5538          
##       Balanced Accuracy : 0.5223          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 6H apex + lip
set.seed(1973)
smile__tree_model_6H <- train(smile_type ~ apex_mean + lip_mean,
  method = "rpart", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_6H$results
##           cp  Accuracy       Kappa AccuracySD   KappaSD
## 1 0.02272727 0.4543895 -0.09300652 0.09708536 0.1932817
## 2 0.03333333 0.4632074 -0.07541557 0.09095422 0.1816019
## 3 0.11515152 0.4866310 -0.03605245 0.03749912 0.0690707
smile__tree_model_6H$coefnames
## [1] "apex_mean" "lip_mean"
varImp(smile__tree_model_6H)
## rpart variable importance
## 
##           Overall
## apex_mean     NaN
## lip_mean      NaN
# summary(smile__tree_model_6H$finalModel)

smile__tree_model_6H_pred <- predict(smile__tree_model_6H, tst_smile)
summary(smile__tree_model_6H_pred)
## spontaneous deliberate  
##           0         142
smile__tree_model_6H_confM <- confusionMatrix(
  smile__tree_model_6H_pred,
  tst_smile$smile_type
)
smile__tree_model_6H_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           0           0
##   deliberate           70          72
##                                           
##                Accuracy : 0.507           
##                  95% CI : (0.4219, 0.5919)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.5336          
##                                           
##                   Kappa : 0               
##                                           
##  Mcnemar's Test P-Value : <2e-16          
##                                           
##             Sensitivity : 0.000           
##             Specificity : 1.000           
##          Pos Pred Value :   NaN           
##          Neg Pred Value : 0.507           
##              Prevalence : 0.493           
##          Detection Rate : 0.000           
##    Detection Prevalence : 0.000           
##       Balanced Accuracy : 0.500           
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_6H.1_pred <- predict(smile__tree_model_6H, tst_smile_boys)
summary(smile__tree_model_6H.1_pred)
## spontaneous deliberate  
##           0          77
smile__tree_model_6H.1_confM <- confusionMatrix(
  smile__tree_model_6H.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_6H.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           0           0
##   deliberate           37          40
##                                           
##                Accuracy : 0.5195          
##                  95% CI : (0.4026, 0.6348)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.5459          
##                                           
##                   Kappa : 0               
##                                           
##  Mcnemar's Test P-Value : 3.252e-09       
##                                           
##             Sensitivity : 0.0000          
##             Specificity : 1.0000          
##          Pos Pred Value :    NaN          
##          Neg Pred Value : 0.5195          
##              Prevalence : 0.4805          
##          Detection Rate : 0.0000          
##    Detection Prevalence : 0.0000          
##       Balanced Accuracy : 0.5000          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_6H.2_pred <- predict(smile__tree_model_6H, tst_smile_girls)
summary(smile__tree_model_6H.2_pred)
## spontaneous deliberate  
##           0          65
smile__tree_model_6H.2_confM <- confusionMatrix(
  smile__tree_model_6H.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_6H.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           0           0
##   deliberate           33          32
##                                          
##                Accuracy : 0.4923         
##                  95% CI : (0.366, 0.6193)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.6452         
##                                          
##                   Kappa : 0              
##                                          
##  Mcnemar's Test P-Value : 2.54e-08       
##                                          
##             Sensitivity : 0.0000         
##             Specificity : 1.0000         
##          Pos Pred Value :    NaN         
##          Neg Pred Value : 0.4923         
##              Prevalence : 0.5077         
##          Detection Rate : 0.0000         
##    Detection Prevalence : 0.0000         
##       Balanced Accuracy : 0.5000         
##                                          
##        'Positive' Class : spontaneous    
## 
# model 6I offset and movement
set.seed(1973)
smile__tree_model_6I <- train(smile_type ~ offset_mean + eye_mean + lip_mean,
  method = "rpart", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_6I$results
##           cp  Accuracy       Kappa AccuracySD    KappaSD
## 1 0.02272727 0.5322081  0.06456196 0.09174672 0.18428052
## 2 0.06666667 0.5407587  0.08370581 0.10511016 0.20533476
## 3 0.16363636 0.4868093 -0.03388104 0.03960046 0.07404332
smile__tree_model_6I$coefnames
## [1] "offset_mean" "eye_mean"    "lip_mean"
varImp(smile__tree_model_6I)
## rpart variable importance
## 
##             Overall
## eye_mean     100.00
## offset_mean   66.59
## lip_mean       0.00
# summary(smile__tree_model_6I$finalModel)
fancyRpartPlot(smile__tree_model_6I$finalModel)

smile__tree_model_6I_pred <- predict(smile__tree_model_6I, tst_smile)
summary(smile__tree_model_6I_pred)
## spontaneous deliberate  
##          41         101
smile__tree_model_6I_confM <- confusionMatrix(
  smile__tree_model_6I_pred,
  tst_smile$smile_type
)
smile__tree_model_6I_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          25          16
##   deliberate           45          56
##                                           
##                Accuracy : 0.5704          
##                  95% CI : (0.4847, 0.6531)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.076642        
##                                           
##                   Kappa : 0.1357          
##                                           
##  Mcnemar's Test P-Value : 0.000337        
##                                           
##             Sensitivity : 0.3571          
##             Specificity : 0.7778          
##          Pos Pred Value : 0.6098          
##          Neg Pred Value : 0.5545          
##              Prevalence : 0.4930          
##          Detection Rate : 0.1761          
##    Detection Prevalence : 0.2887          
##       Balanced Accuracy : 0.5675          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_6I.1_pred <- predict(smile__tree_model_6I, tst_smile_boys)
summary(smile__tree_model_6I.1_pred)
## spontaneous deliberate  
##          22          55
smile__tree_model_6I.1_confM <- confusionMatrix(
  smile__tree_model_6I.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_6I.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          13           9
##   deliberate           24          31
##                                           
##                Accuracy : 0.5714          
##                  95% CI : (0.4535, 0.6837)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.21259         
##                                           
##                   Kappa : 0.1283          
##                                           
##  Mcnemar's Test P-Value : 0.01481         
##                                           
##             Sensitivity : 0.3514          
##             Specificity : 0.7750          
##          Pos Pred Value : 0.5909          
##          Neg Pred Value : 0.5636          
##              Prevalence : 0.4805          
##          Detection Rate : 0.1688          
##    Detection Prevalence : 0.2857          
##       Balanced Accuracy : 0.5632          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_6I.2_pred <- predict(smile__tree_model_6I, tst_smile_girls)
summary(smile__tree_model_6I.2_pred)
## spontaneous deliberate  
##          19          46
smile__tree_model_6I.2_confM <- confusionMatrix(
  smile__tree_model_6I.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_6I.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          12           7
##   deliberate           21          25
##                                           
##                Accuracy : 0.5692          
##                  95% CI : (0.4404, 0.6915)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.19273         
##                                           
##                   Kappa : 0.1439          
##                                           
##  Mcnemar's Test P-Value : 0.01402         
##                                           
##             Sensitivity : 0.3636          
##             Specificity : 0.7812          
##          Pos Pred Value : 0.6316          
##          Neg Pred Value : 0.5435          
##              Prevalence : 0.5077          
##          Detection Rate : 0.1846          
##    Detection Prevalence : 0.2923          
##       Balanced Accuracy : 0.5724          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 6J offset + eye
set.seed(1973)
smile__tree_model_6J <- train(smile_type ~ offset_mean + eye_mean,
  method = "rpart", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_6J$results
##           cp  Accuracy       Kappa AccuracySD    KappaSD
## 1 0.03030303 0.5642547  0.12621182 0.07907261 0.15669999
## 2 0.06666667 0.5862132  0.16762689 0.10072271 0.20239814
## 3 0.16363636 0.4868093 -0.03388104 0.03960046 0.07404332
smile__tree_model_6J$coefnames
## [1] "offset_mean" "eye_mean"
varImp(smile__tree_model_6J)
## rpart variable importance
## 
##             Overall
## eye_mean        100
## offset_mean       0
# summary(smile__tree_model_6J$finalModel)
fancyRpartPlot(smile__tree_model_6J$finalModel)

smile__tree_model_6J_pred <- predict(smile__tree_model_6J, tst_smile)
summary(smile__tree_model_6J_pred)
## spontaneous deliberate  
##          41         101
smile__tree_model_6J_confM <- confusionMatrix(
  smile__tree_model_6J_pred,
  tst_smile$smile_type
)
smile__tree_model_6J_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          25          16
##   deliberate           45          56
##                                           
##                Accuracy : 0.5704          
##                  95% CI : (0.4847, 0.6531)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.076642        
##                                           
##                   Kappa : 0.1357          
##                                           
##  Mcnemar's Test P-Value : 0.000337        
##                                           
##             Sensitivity : 0.3571          
##             Specificity : 0.7778          
##          Pos Pred Value : 0.6098          
##          Neg Pred Value : 0.5545          
##              Prevalence : 0.4930          
##          Detection Rate : 0.1761          
##    Detection Prevalence : 0.2887          
##       Balanced Accuracy : 0.5675          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_6J.1_pred <- predict(smile__tree_model_6J, tst_smile_boys)
summary(smile__tree_model_6J.1_pred)
## spontaneous deliberate  
##          22          55
smile__tree_model_6J.1_confM <- confusionMatrix(
  smile__tree_model_6J.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_6J.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          13           9
##   deliberate           24          31
##                                           
##                Accuracy : 0.5714          
##                  95% CI : (0.4535, 0.6837)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.21259         
##                                           
##                   Kappa : 0.1283          
##                                           
##  Mcnemar's Test P-Value : 0.01481         
##                                           
##             Sensitivity : 0.3514          
##             Specificity : 0.7750          
##          Pos Pred Value : 0.5909          
##          Neg Pred Value : 0.5636          
##              Prevalence : 0.4805          
##          Detection Rate : 0.1688          
##    Detection Prevalence : 0.2857          
##       Balanced Accuracy : 0.5632          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_6J.2_pred <- predict(smile__tree_model_6J, tst_smile_girls)
summary(smile__tree_model_6J.2_pred)
## spontaneous deliberate  
##          19          46
smile__tree_model_6J.2_confM <- confusionMatrix(
  smile__tree_model_6J.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_6J.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          12           7
##   deliberate           21          25
##                                           
##                Accuracy : 0.5692          
##                  95% CI : (0.4404, 0.6915)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.19273         
##                                           
##                   Kappa : 0.1439          
##                                           
##  Mcnemar's Test P-Value : 0.01402         
##                                           
##             Sensitivity : 0.3636          
##             Specificity : 0.7812          
##          Pos Pred Value : 0.6316          
##          Neg Pred Value : 0.5435          
##              Prevalence : 0.5077          
##          Detection Rate : 0.1846          
##    Detection Prevalence : 0.2923          
##       Balanced Accuracy : 0.5724          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 6K offset + lip
set.seed(1973)
smile__tree_model_6K <- train(smile_type ~ offset_mean + lip_mean,
  method = "rpart", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_6K$results
##           cp  Accuracy      Kappa AccuracySD   KappaSD
## 1 0.02424242 0.5676693 0.13426752 0.07837002 0.1574382
## 2 0.03434343 0.5552640 0.11098029 0.08076035 0.1634492
## 3 0.07878788 0.5075869 0.02036637 0.08687993 0.1683719
smile__tree_model_6K$coefnames
## [1] "offset_mean" "lip_mean"
varImp(smile__tree_model_6K)
## rpart variable importance
## 
##             Overall
## lip_mean        100
## offset_mean       0
# summary(smile__tree_model_6K$finalModel)
fancyRpartPlot(smile__tree_model_6K$finalModel)

smile__tree_model_6K_pred <- predict(smile__tree_model_6K, tst_smile)
summary(smile__tree_model_6K_pred)
## spontaneous deliberate  
##          60          82
smile__tree_model_6K_confM <- confusionMatrix(
  smile__tree_model_6K_pred,
  tst_smile$smile_type
)
smile__tree_model_6K_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          37          23
##   deliberate           33          49
##                                           
##                Accuracy : 0.6056          
##                  95% CI : (0.5202, 0.6865)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.01151         
##                                           
##                   Kappa : 0.2095          
##                                           
##  Mcnemar's Test P-Value : 0.22910         
##                                           
##             Sensitivity : 0.5286          
##             Specificity : 0.6806          
##          Pos Pred Value : 0.6167          
##          Neg Pred Value : 0.5976          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2606          
##    Detection Prevalence : 0.4225          
##       Balanced Accuracy : 0.6046          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_6K.1_pred <- predict(smile__tree_model_6K, tst_smile_boys)
summary(smile__tree_model_6K.1_pred)
## spontaneous deliberate  
##          35          42
smile__tree_model_6K.1_confM <- confusionMatrix(
  smile__tree_model_6K.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_6K.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          20          15
##   deliberate           17          25
##                                           
##                Accuracy : 0.5844          
##                  95% CI : (0.4664, 0.6957)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.1523          
##                                           
##                   Kappa : 0.1659          
##                                           
##  Mcnemar's Test P-Value : 0.8597          
##                                           
##             Sensitivity : 0.5405          
##             Specificity : 0.6250          
##          Pos Pred Value : 0.5714          
##          Neg Pred Value : 0.5952          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2597          
##    Detection Prevalence : 0.4545          
##       Balanced Accuracy : 0.5828          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_6K.2_pred <- predict(smile__tree_model_6K, tst_smile_girls)
summary(smile__tree_model_6K.2_pred)
## spontaneous deliberate  
##          25          40
smile__tree_model_6K.2_confM <- confusionMatrix(
  smile__tree_model_6K.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_6K.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          17           8
##   deliberate           16          24
##                                          
##                Accuracy : 0.6308         
##                  95% CI : (0.502, 0.7472)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.03086        
##                                          
##                   Kappa : 0.2642         
##                                          
##  Mcnemar's Test P-Value : 0.15304        
##                                          
##             Sensitivity : 0.5152         
##             Specificity : 0.7500         
##          Pos Pred Value : 0.6800         
##          Neg Pred Value : 0.6000         
##              Prevalence : 0.5077         
##          Detection Rate : 0.2615         
##    Detection Prevalence : 0.3846         
##       Balanced Accuracy : 0.6326         
##                                          
##        'Positive' Class : spontaneous    
## 
# Model 7: dynamics and AU's
set.seed(1973)
smile__tree_model_7 <- train(smile_type ~ AU01_r_mean + AU02_r_mean +
  AU04_r_mean + AU05_r_mean + AU06_r_mean +
  AU07_r_mean + AU09_r_mean + AU10_r_mean +
  AU12_r_mean + AU14_r_mean + AU15_r_mean +
  AU17_r_mean + AU20_r_mean + AU23_r_mean +
  AU25_r_mean + AU26_r_mean + AU45_r_mean +
  onset_mean + apex_mean + offset_mean,
method = "rpart", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_7$results
##           cp  Accuracy      Kappa AccuracySD   KappaSD
## 1 0.04848485 0.5368761 0.07420769 0.07460008 0.1488441
## 2 0.05252525 0.5308155 0.05932530 0.07759515 0.1551832
## 3 0.22424242 0.5255849 0.04429576 0.04913641 0.0997257
smile__tree_model_7$coefnames
##  [1] "AU01_r_mean" "AU02_r_mean" "AU04_r_mean" "AU05_r_mean" "AU06_r_mean"
##  [6] "AU07_r_mean" "AU09_r_mean" "AU10_r_mean" "AU12_r_mean" "AU14_r_mean"
## [11] "AU15_r_mean" "AU17_r_mean" "AU20_r_mean" "AU23_r_mean" "AU25_r_mean"
## [16] "AU26_r_mean" "AU45_r_mean" "onset_mean"  "apex_mean"   "offset_mean"
varImp(smile__tree_model_7)
## rpart variable importance
## 
##             Overall
## AU45_r_mean  100.00
## AU01_r_mean   81.66
## AU25_r_mean   63.30
## AU09_r_mean   56.35
## AU10_r_mean   54.54
## AU05_r_mean   52.28
## apex_mean     38.50
## AU14_r_mean   21.58
## AU12_r_mean    0.00
## AU23_r_mean    0.00
## AU07_r_mean    0.00
## AU02_r_mean    0.00
## AU04_r_mean    0.00
## offset_mean    0.00
## AU06_r_mean    0.00
## onset_mean     0.00
## AU17_r_mean    0.00
## AU20_r_mean    0.00
## AU26_r_mean    0.00
## AU15_r_mean    0.00
# summary(smile__tree_model_7$finalModel)
fancyRpartPlot(smile__tree_model_7$finalModel)

smile__tree_model_7_pred <- predict(smile__tree_model_7, tst_smile)
summary(smile__tree_model_7_pred)
## spontaneous deliberate  
##          84          58
smile__tree_model_7_confM <- confusionMatrix(
  smile__tree_model_7_pred,
  tst_smile$smile_type
)
smile__tree_model_7_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          44          40
##   deliberate           26          32
##                                           
##                Accuracy : 0.5352          
##                  95% CI : (0.4497, 0.6193)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.2786          
##                                           
##                   Kappa : 0.0728          
##                                           
##  Mcnemar's Test P-Value : 0.1096          
##                                           
##             Sensitivity : 0.6286          
##             Specificity : 0.4444          
##          Pos Pred Value : 0.5238          
##          Neg Pred Value : 0.5517          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3099          
##    Detection Prevalence : 0.5915          
##       Balanced Accuracy : 0.5365          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_7.1_pred <- predict(smile__tree_model_7, tst_smile_boys)
summary(smile__tree_model_7.1_pred)
## spontaneous deliberate  
##          40          37
smile__tree_model_7.1_confM <- confusionMatrix(
  smile__tree_model_7.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_7.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          20          20
##   deliberate           17          20
##                                           
##                Accuracy : 0.5195          
##                  95% CI : (0.4026, 0.6348)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.5459          
##                                           
##                   Kappa : 0.0404          
##                                           
##  Mcnemar's Test P-Value : 0.7423          
##                                           
##             Sensitivity : 0.5405          
##             Specificity : 0.5000          
##          Pos Pred Value : 0.5000          
##          Neg Pred Value : 0.5405          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2597          
##    Detection Prevalence : 0.5195          
##       Balanced Accuracy : 0.5203          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_7.2_pred <- predict(smile__tree_model_7, tst_smile_girls)
summary(smile__tree_model_7.2_pred)
## spontaneous deliberate  
##          44          21
smile__tree_model_7.2_confM <- confusionMatrix(
  smile__tree_model_7.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_7.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          24          20
##   deliberate            9          12
##                                           
##                Accuracy : 0.5538          
##                  95% CI : (0.4253, 0.6773)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.26784         
##                                           
##                   Kappa : 0.1028          
##                                           
##  Mcnemar's Test P-Value : 0.06332         
##                                           
##             Sensitivity : 0.7273          
##             Specificity : 0.3750          
##          Pos Pred Value : 0.5455          
##          Neg Pred Value : 0.5714          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3692          
##    Detection Prevalence : 0.6769          
##       Balanced Accuracy : 0.5511          
##                                           
##        'Positive' Class : spontaneous     
## 
# 7A AU's + onset

set.seed(1973)
smile__tree_model_7A <- train(smile_type ~ AU01_r_mean + AU02_r_mean +
  AU04_r_mean + AU05_r_mean + AU06_r_mean +
  AU07_r_mean + AU09_r_mean + AU10_r_mean +
  AU12_r_mean + AU14_r_mean + AU15_r_mean +
  AU17_r_mean + AU20_r_mean + AU23_r_mean +
  AU25_r_mean + AU26_r_mean + AU45_r_mean +
  onset_mean,
method = "rpart", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_7A$results
##           cp  Accuracy      Kappa AccuracySD   KappaSD
## 1 0.03030303 0.5636141 0.12907456 0.08437636 0.1685849
## 2 0.05252525 0.5308155 0.05932530 0.07759515 0.1551832
## 3 0.22424242 0.5255849 0.04429576 0.04913641 0.0997257
smile__tree_model_7A$coefnames
##  [1] "AU01_r_mean" "AU02_r_mean" "AU04_r_mean" "AU05_r_mean" "AU06_r_mean"
##  [6] "AU07_r_mean" "AU09_r_mean" "AU10_r_mean" "AU12_r_mean" "AU14_r_mean"
## [11] "AU15_r_mean" "AU17_r_mean" "AU20_r_mean" "AU23_r_mean" "AU25_r_mean"
## [16] "AU26_r_mean" "AU45_r_mean" "onset_mean"
varImp(smile__tree_model_7A)
## rpart variable importance
## 
##             Overall
## AU45_r_mean  100.00
## AU01_r_mean   81.66
## AU25_r_mean   77.78
## AU09_r_mean   73.78
## AU10_r_mean   54.54
## AU05_r_mean   52.28
## AU14_r_mean   21.58
## AU12_r_mean    0.00
## AU23_r_mean    0.00
## AU07_r_mean    0.00
## AU02_r_mean    0.00
## AU04_r_mean    0.00
## AU06_r_mean    0.00
## onset_mean     0.00
## AU17_r_mean    0.00
## AU20_r_mean    0.00
## AU26_r_mean    0.00
## AU15_r_mean    0.00
# summary(smile__tree_model_7A$finalModel)
fancyRpartPlot(smile__tree_model_7A$finalModel)

smile__tree_model_7A_pred <- predict(smile__tree_model_7A, tst_smile)
summary(smile__tree_model_7A_pred)
## spontaneous deliberate  
##          84          58
smile__tree_model_7A_confM <- confusionMatrix(
  smile__tree_model_7A_pred,
  tst_smile$smile_type
)
smile__tree_model_7A_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          44          40
##   deliberate           26          32
##                                           
##                Accuracy : 0.5352          
##                  95% CI : (0.4497, 0.6193)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.2786          
##                                           
##                   Kappa : 0.0728          
##                                           
##  Mcnemar's Test P-Value : 0.1096          
##                                           
##             Sensitivity : 0.6286          
##             Specificity : 0.4444          
##          Pos Pred Value : 0.5238          
##          Neg Pred Value : 0.5517          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3099          
##    Detection Prevalence : 0.5915          
##       Balanced Accuracy : 0.5365          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_7A.1_pred <- predict(smile__tree_model_7A, tst_smile_boys)
summary(smile__tree_model_7A.1_pred)
## spontaneous deliberate  
##          40          37
smile__tree_model_7A.1_confM <- confusionMatrix(
  smile__tree_model_7A.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_7A.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          20          20
##   deliberate           17          20
##                                           
##                Accuracy : 0.5195          
##                  95% CI : (0.4026, 0.6348)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.5459          
##                                           
##                   Kappa : 0.0404          
##                                           
##  Mcnemar's Test P-Value : 0.7423          
##                                           
##             Sensitivity : 0.5405          
##             Specificity : 0.5000          
##          Pos Pred Value : 0.5000          
##          Neg Pred Value : 0.5405          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2597          
##    Detection Prevalence : 0.5195          
##       Balanced Accuracy : 0.5203          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_7A.2_pred <- predict(smile__tree_model_7A, tst_smile_girls)
summary(smile__tree_model_7A.2_pred)
## spontaneous deliberate  
##          44          21
smile__tree_model_7A.2_confM <- confusionMatrix(
  smile__tree_model_7A.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_7A.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          24          20
##   deliberate            9          12
##                                           
##                Accuracy : 0.5538          
##                  95% CI : (0.4253, 0.6773)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.26784         
##                                           
##                   Kappa : 0.1028          
##                                           
##  Mcnemar's Test P-Value : 0.06332         
##                                           
##             Sensitivity : 0.7273          
##             Specificity : 0.3750          
##          Pos Pred Value : 0.5455          
##          Neg Pred Value : 0.5714          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3692          
##    Detection Prevalence : 0.6769          
##       Balanced Accuracy : 0.5511          
##                                           
##        'Positive' Class : spontaneous     
## 
# 7B AU's + apex

set.seed(1973)
smile__tree_model_7B <- train(smile_type ~ AU01_r_mean + AU02_r_mean +
  AU04_r_mean + AU05_r_mean + AU06_r_mean +
  AU07_r_mean + AU09_r_mean + AU10_r_mean +
  AU12_r_mean + AU14_r_mean + AU15_r_mean +
  AU17_r_mean + AU20_r_mean + AU23_r_mean +
  AU25_r_mean + AU26_r_mean + AU45_r_mean +
  apex_mean,
method = "rpart", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_7B$results
##           cp  Accuracy      Kappa AccuracySD   KappaSD
## 1 0.04848485 0.5368761 0.07420769 0.07460008 0.1488441
## 2 0.05252525 0.5308155 0.05932530 0.07759515 0.1551832
## 3 0.22424242 0.5255849 0.04429576 0.04913641 0.0997257
smile__tree_model_7B$coefnames
##  [1] "AU01_r_mean" "AU02_r_mean" "AU04_r_mean" "AU05_r_mean" "AU06_r_mean"
##  [6] "AU07_r_mean" "AU09_r_mean" "AU10_r_mean" "AU12_r_mean" "AU14_r_mean"
## [11] "AU15_r_mean" "AU17_r_mean" "AU20_r_mean" "AU23_r_mean" "AU25_r_mean"
## [16] "AU26_r_mean" "AU45_r_mean" "apex_mean"
varImp(smile__tree_model_7B)
## rpart variable importance
## 
##             Overall
## AU45_r_mean  100.00
## AU01_r_mean   81.66
## AU25_r_mean   63.30
## AU09_r_mean   56.35
## AU10_r_mean   54.54
## AU05_r_mean   52.28
## apex_mean     38.50
## AU14_r_mean   21.58
## AU12_r_mean    0.00
## AU23_r_mean    0.00
## AU07_r_mean    0.00
## AU02_r_mean    0.00
## AU04_r_mean    0.00
## AU06_r_mean    0.00
## AU17_r_mean    0.00
## AU20_r_mean    0.00
## AU26_r_mean    0.00
## AU15_r_mean    0.00
# summary(smile__tree_model_7B$finalModel)
fancyRpartPlot(smile__tree_model_7B$finalModel)

smile__tree_model_7B_pred <- predict(smile__tree_model_7B, tst_smile)
summary(smile__tree_model_7B_pred)
## spontaneous deliberate  
##          84          58
smile__tree_model_7B_confM <- confusionMatrix(
  smile__tree_model_7B_pred,
  tst_smile$smile_type
)
smile__tree_model_7B_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          44          40
##   deliberate           26          32
##                                           
##                Accuracy : 0.5352          
##                  95% CI : (0.4497, 0.6193)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.2786          
##                                           
##                   Kappa : 0.0728          
##                                           
##  Mcnemar's Test P-Value : 0.1096          
##                                           
##             Sensitivity : 0.6286          
##             Specificity : 0.4444          
##          Pos Pred Value : 0.5238          
##          Neg Pred Value : 0.5517          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3099          
##    Detection Prevalence : 0.5915          
##       Balanced Accuracy : 0.5365          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_7B.1_pred <- predict(smile__tree_model_7B, tst_smile_boys)
summary(smile__tree_model_7B.1_pred)
## spontaneous deliberate  
##          40          37
smile__tree_model_7B.1_confM <- confusionMatrix(
  smile__tree_model_7B.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_7B.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          20          20
##   deliberate           17          20
##                                           
##                Accuracy : 0.5195          
##                  95% CI : (0.4026, 0.6348)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.5459          
##                                           
##                   Kappa : 0.0404          
##                                           
##  Mcnemar's Test P-Value : 0.7423          
##                                           
##             Sensitivity : 0.5405          
##             Specificity : 0.5000          
##          Pos Pred Value : 0.5000          
##          Neg Pred Value : 0.5405          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2597          
##    Detection Prevalence : 0.5195          
##       Balanced Accuracy : 0.5203          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_7B.2_pred <- predict(smile__tree_model_7B, tst_smile_girls)
summary(smile__tree_model_7B.2_pred)
## spontaneous deliberate  
##          44          21
smile__tree_model_7B.2_confM <- confusionMatrix(
  smile__tree_model_7B.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_7B.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          24          20
##   deliberate            9          12
##                                           
##                Accuracy : 0.5538          
##                  95% CI : (0.4253, 0.6773)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.26784         
##                                           
##                   Kappa : 0.1028          
##                                           
##  Mcnemar's Test P-Value : 0.06332         
##                                           
##             Sensitivity : 0.7273          
##             Specificity : 0.3750          
##          Pos Pred Value : 0.5455          
##          Neg Pred Value : 0.5714          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3692          
##    Detection Prevalence : 0.6769          
##       Balanced Accuracy : 0.5511          
##                                           
##        'Positive' Class : spontaneous     
## 
# 7C AU's + offset

set.seed(1973)
smile__tree_model_7C <- train(smile_type ~ AU01_r_mean + AU02_r_mean +
  AU04_r_mean + AU05_r_mean + AU06_r_mean +
  AU07_r_mean + AU09_r_mean + AU10_r_mean +
  AU12_r_mean + AU14_r_mean + AU15_r_mean +
  AU17_r_mean + AU20_r_mean + AU23_r_mean +
  AU25_r_mean + AU26_r_mean + AU45_r_mean +
  offset_mean,
method = "rpart", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_7C$results
##           cp  Accuracy      Kappa AccuracySD   KappaSD
## 1 0.03030303 0.5666444 0.13557324 0.08539890 0.1707513
## 2 0.05252525 0.5308155 0.05932530 0.07759515 0.1551832
## 3 0.22424242 0.5255849 0.04429576 0.04913641 0.0997257
smile__tree_model_7C$coefnames
##  [1] "AU01_r_mean" "AU02_r_mean" "AU04_r_mean" "AU05_r_mean" "AU06_r_mean"
##  [6] "AU07_r_mean" "AU09_r_mean" "AU10_r_mean" "AU12_r_mean" "AU14_r_mean"
## [11] "AU15_r_mean" "AU17_r_mean" "AU20_r_mean" "AU23_r_mean" "AU25_r_mean"
## [16] "AU26_r_mean" "AU45_r_mean" "offset_mean"
varImp(smile__tree_model_7C)
## rpart variable importance
## 
##             Overall
## AU45_r_mean  100.00
## AU01_r_mean   81.66
## AU25_r_mean   77.78
## AU09_r_mean   73.78
## AU10_r_mean   54.54
## AU05_r_mean   52.28
## AU14_r_mean   21.58
## AU12_r_mean    0.00
## AU23_r_mean    0.00
## AU07_r_mean    0.00
## AU02_r_mean    0.00
## AU04_r_mean    0.00
## AU06_r_mean    0.00
## offset_mean    0.00
## AU17_r_mean    0.00
## AU20_r_mean    0.00
## AU26_r_mean    0.00
## AU15_r_mean    0.00
# summary(smile__tree_model_7C$finalModel)
fancyRpartPlot(smile__tree_model_7C$finalModel)

smile__tree_model_7C_pred <- predict(smile__tree_model_7C, tst_smile)
summary(smile__tree_model_7C_pred)
## spontaneous deliberate  
##          84          58
smile__tree_model_7C_confM <- confusionMatrix(
  smile__tree_model_7C_pred,
  tst_smile$smile_type
)
smile__tree_model_7C_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          44          40
##   deliberate           26          32
##                                           
##                Accuracy : 0.5352          
##                  95% CI : (0.4497, 0.6193)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.2786          
##                                           
##                   Kappa : 0.0728          
##                                           
##  Mcnemar's Test P-Value : 0.1096          
##                                           
##             Sensitivity : 0.6286          
##             Specificity : 0.4444          
##          Pos Pred Value : 0.5238          
##          Neg Pred Value : 0.5517          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3099          
##    Detection Prevalence : 0.5915          
##       Balanced Accuracy : 0.5365          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_7C.1_pred <- predict(smile__tree_model_7C, tst_smile_boys)
summary(smile__tree_model_7C.1_pred)
## spontaneous deliberate  
##          40          37
smile__tree_model_7C.1_confM <- confusionMatrix(
  smile__tree_model_7C.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_7C.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          20          20
##   deliberate           17          20
##                                           
##                Accuracy : 0.5195          
##                  95% CI : (0.4026, 0.6348)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.5459          
##                                           
##                   Kappa : 0.0404          
##                                           
##  Mcnemar's Test P-Value : 0.7423          
##                                           
##             Sensitivity : 0.5405          
##             Specificity : 0.5000          
##          Pos Pred Value : 0.5000          
##          Neg Pred Value : 0.5405          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2597          
##    Detection Prevalence : 0.5195          
##       Balanced Accuracy : 0.5203          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_7C.2_pred <- predict(smile__tree_model_7C, tst_smile_girls)
summary(smile__tree_model_7C.2_pred)
## spontaneous deliberate  
##          44          21
smile__tree_model_7C.2_confM <- confusionMatrix(
  smile__tree_model_7C.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_7C.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          24          20
##   deliberate            9          12
##                                           
##                Accuracy : 0.5538          
##                  95% CI : (0.4253, 0.6773)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.26784         
##                                           
##                   Kappa : 0.1028          
##                                           
##  Mcnemar's Test P-Value : 0.06332         
##                                           
##             Sensitivity : 0.7273          
##             Specificity : 0.3750          
##          Pos Pred Value : 0.5455          
##          Neg Pred Value : 0.5714          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3692          
##    Detection Prevalence : 0.6769          
##       Balanced Accuracy : 0.5511          
##                                           
##        'Positive' Class : spontaneous     
## 
# 7D
set.seed(1973)
smile__tree_model_7D <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + onset_mean + apex_mean +
  offset_mean,
method = "rpart", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_7D$results
##           cp  Accuracy      Kappa AccuracySD    KappaSD
## 1 0.03636364 0.5584837 0.11790741 0.03491922 0.06900019
## 2 0.05454545 0.5493928 0.09982095 0.04575070 0.09183336
## 3 0.18787879 0.5223708 0.04901466 0.03672728 0.07788091
smile__tree_model_7D$coefnames
## [1] "AU06_r_mean" "AU12_r_mean" "AU45_r_mean" "onset_mean"  "apex_mean"  
## [6] "offset_mean"
varImp(smile__tree_model_7D)
## rpart variable importance
## 
##             Overall
## AU45_r_mean  100.00
## offset_mean   69.75
## AU06_r_mean   48.99
## onset_mean    46.87
## apex_mean     39.60
## AU12_r_mean    0.00
# summary(smile__tree_model_7D$finalModel)
fancyRpartPlot(smile__tree_model_7D$finalModel)

smile__tree_model_7D_pred <- predict(smile__tree_model_7D, tst_smile)
summary(smile__tree_model_7D_pred)
## spontaneous deliberate  
##          92          50
smile__tree_model_7D_confM <- confusionMatrix(
  smile__tree_model_7D_pred,
  tst_smile$smile_type
)
smile__tree_model_7D_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          46          46
##   deliberate           24          26
##                                           
##                Accuracy : 0.507           
##                  95% CI : (0.4219, 0.5919)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.53358         
##                                           
##                   Kappa : 0.0182          
##                                           
##  Mcnemar's Test P-Value : 0.01207         
##                                           
##             Sensitivity : 0.6571          
##             Specificity : 0.3611          
##          Pos Pred Value : 0.5000          
##          Neg Pred Value : 0.5200          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3239          
##    Detection Prevalence : 0.6479          
##       Balanced Accuracy : 0.5091          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_7D.1_pred <- predict(smile__tree_model_7D, tst_smile_boys)
summary(smile__tree_model_7D.1_pred)
## spontaneous deliberate  
##          49          28
smile__tree_model_7D.1_confM <- confusionMatrix(
  smile__tree_model_7D.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_7D.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          24          25
##   deliberate           13          15
##                                         
##                Accuracy : 0.5065        
##                  95% CI : (0.39, 0.6224)
##     No Information Rate : 0.5195        
##     P-Value [Acc > NIR] : 0.63425       
##                                         
##                   Kappa : 0.0234        
##                                         
##  Mcnemar's Test P-Value : 0.07435       
##                                         
##             Sensitivity : 0.6486        
##             Specificity : 0.3750        
##          Pos Pred Value : 0.4898        
##          Neg Pred Value : 0.5357        
##              Prevalence : 0.4805        
##          Detection Rate : 0.3117        
##    Detection Prevalence : 0.6364        
##       Balanced Accuracy : 0.5118        
##                                         
##        'Positive' Class : spontaneous   
## 
set.seed(1973)
smile__tree_model_7D.2_pred <- predict(smile__tree_model_7D, tst_smile_girls)
summary(smile__tree_model_7D.2_pred)
## spontaneous deliberate  
##          43          22
smile__tree_model_7D.2_confM <- confusionMatrix(
  smile__tree_model_7D.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_7D.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          22          21
##   deliberate           11          11
##                                          
##                Accuracy : 0.5077         
##                  95% CI : (0.3807, 0.634)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.5495         
##                                          
##                   Kappa : 0.0105         
##                                          
##  Mcnemar's Test P-Value : 0.1116         
##                                          
##             Sensitivity : 0.6667         
##             Specificity : 0.3438         
##          Pos Pred Value : 0.5116         
##          Neg Pred Value : 0.5000         
##              Prevalence : 0.5077         
##          Detection Rate : 0.3385         
##    Detection Prevalence : 0.6615         
##       Balanced Accuracy : 0.5052         
##                                          
##        'Positive' Class : spontaneous    
## 
# 7E

set.seed(1973)
smile__tree_model_7E <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + onset_mean,
method = "rpart", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_7E$results
##           cp  Accuracy      Kappa AccuracySD    KappaSD
## 1 0.03636364 0.5707832 0.14319007 0.03027685 0.06296834
## 2 0.06060606 0.5464516 0.09717643 0.04388348 0.08896946
## 3 0.18787879 0.5223708 0.04901466 0.03672728 0.07788091
smile__tree_model_7E$coefnames
## [1] "AU06_r_mean" "AU12_r_mean" "AU45_r_mean" "onset_mean"
varImp(smile__tree_model_7E)
## rpart variable importance
## 
##             Overall
## AU45_r_mean  100.00
## AU06_r_mean   31.92
## onset_mean    29.09
## AU12_r_mean    0.00
# summary(smile__tree_model_7E$finalModel)
fancyRpartPlot(smile__tree_model_7E$finalModel)

smile__tree_model_7E_pred <- predict(smile__tree_model_7E, tst_smile)
summary(smile__tree_model_7E_pred)
## spontaneous deliberate  
##          85          57
smile__tree_model_7E_confM <- confusionMatrix(
  smile__tree_model_7E_pred,
  tst_smile$smile_type
)
smile__tree_model_7E_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          44          41
##   deliberate           26          31
##                                           
##                Accuracy : 0.5282          
##                  95% CI : (0.4427, 0.6124)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.3376          
##                                           
##                   Kappa : 0.059           
##                                           
##  Mcnemar's Test P-Value : 0.0872          
##                                           
##             Sensitivity : 0.6286          
##             Specificity : 0.4306          
##          Pos Pred Value : 0.5176          
##          Neg Pred Value : 0.5439          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3099          
##    Detection Prevalence : 0.5986          
##       Balanced Accuracy : 0.5296          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_7E.1_pred <- predict(smile__tree_model_7E, tst_smile_boys)
summary(smile__tree_model_7E.1_pred)
## spontaneous deliberate  
##          45          32
smile__tree_model_7E.1_confM <- confusionMatrix(
  smile__tree_model_7E.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_7E.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          23          22
##   deliberate           14          18
##                                           
##                Accuracy : 0.5325          
##                  95% CI : (0.4152, 0.6471)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.4552          
##                                           
##                   Kappa : 0.071           
##                                           
##  Mcnemar's Test P-Value : 0.2433          
##                                           
##             Sensitivity : 0.6216          
##             Specificity : 0.4500          
##          Pos Pred Value : 0.5111          
##          Neg Pred Value : 0.5625          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2987          
##    Detection Prevalence : 0.5844          
##       Balanced Accuracy : 0.5358          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_7E.2_pred <- predict(smile__tree_model_7E, tst_smile_girls)
summary(smile__tree_model_7E.2_pred)
## spontaneous deliberate  
##          40          25
smile__tree_model_7E.2_confM <- confusionMatrix(
  smile__tree_model_7E.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_7E.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          21          19
##   deliberate           12          13
##                                           
##                Accuracy : 0.5231          
##                  95% CI : (0.3954, 0.6485)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.4510          
##                                           
##                   Kappa : 0.0428          
##                                           
##  Mcnemar's Test P-Value : 0.2812          
##                                           
##             Sensitivity : 0.6364          
##             Specificity : 0.4062          
##          Pos Pred Value : 0.5250          
##          Neg Pred Value : 0.5200          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3231          
##    Detection Prevalence : 0.6154          
##       Balanced Accuracy : 0.5213          
##                                           
##        'Positive' Class : spontaneous     
## 
# 7F

set.seed(1973)
smile__tree_model_7F <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + apex_mean,
method = "rpart", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_7F$results
##           cp  Accuracy      Kappa AccuracySD    KappaSD
## 1 0.04242424 0.5706941 0.14076293 0.03491488 0.07078494
## 2 0.06060606 0.5464516 0.09717643 0.04388348 0.08896946
## 3 0.18787879 0.5223708 0.04901466 0.03672728 0.07788091
smile__tree_model_7F$coefnames
## [1] "AU06_r_mean" "AU12_r_mean" "AU45_r_mean" "apex_mean"
varImp(smile__tree_model_7F)
## rpart variable importance
## 
##             Overall
## AU45_r_mean  100.00
## AU06_r_mean   31.92
## apex_mean     19.39
## AU12_r_mean    0.00
# summary(smile__tree_model_7F$finalModel)
fancyRpartPlot(smile__tree_model_7F$finalModel)

smile__tree_model_7F_pred <- predict(smile__tree_model_7F, tst_smile)
summary(smile__tree_model_7F_pred)
## spontaneous deliberate  
##          85          57
smile__tree_model_7F_confM <- confusionMatrix(
  smile__tree_model_7F_pred,
  tst_smile$smile_type
)
smile__tree_model_7F_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          44          41
##   deliberate           26          31
##                                           
##                Accuracy : 0.5282          
##                  95% CI : (0.4427, 0.6124)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.3376          
##                                           
##                   Kappa : 0.059           
##                                           
##  Mcnemar's Test P-Value : 0.0872          
##                                           
##             Sensitivity : 0.6286          
##             Specificity : 0.4306          
##          Pos Pred Value : 0.5176          
##          Neg Pred Value : 0.5439          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3099          
##    Detection Prevalence : 0.5986          
##       Balanced Accuracy : 0.5296          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_7F.1_pred <- predict(smile__tree_model_7F, tst_smile_boys)
summary(smile__tree_model_7F.1_pred)
## spontaneous deliberate  
##          45          32
smile__tree_model_7F.1_confM <- confusionMatrix(
  smile__tree_model_7F.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_7F.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          23          22
##   deliberate           14          18
##                                           
##                Accuracy : 0.5325          
##                  95% CI : (0.4152, 0.6471)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.4552          
##                                           
##                   Kappa : 0.071           
##                                           
##  Mcnemar's Test P-Value : 0.2433          
##                                           
##             Sensitivity : 0.6216          
##             Specificity : 0.4500          
##          Pos Pred Value : 0.5111          
##          Neg Pred Value : 0.5625          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2987          
##    Detection Prevalence : 0.5844          
##       Balanced Accuracy : 0.5358          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_7F.2_pred <- predict(smile__tree_model_7F, tst_smile_girls)
summary(smile__tree_model_7F.2_pred)
## spontaneous deliberate  
##          40          25
smile__tree_model_7F.2_confM <- confusionMatrix(
  smile__tree_model_7F.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_7F.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          21          19
##   deliberate           12          13
##                                           
##                Accuracy : 0.5231          
##                  95% CI : (0.3954, 0.6485)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.4510          
##                                           
##                   Kappa : 0.0428          
##                                           
##  Mcnemar's Test P-Value : 0.2812          
##                                           
##             Sensitivity : 0.6364          
##             Specificity : 0.4062          
##          Pos Pred Value : 0.5250          
##          Neg Pred Value : 0.5200          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3231          
##    Detection Prevalence : 0.6154          
##       Balanced Accuracy : 0.5213          
##                                           
##        'Positive' Class : spontaneous     
## 
# 7G

set.seed(1973)
smile__tree_model_7G <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + offset_mean,
method = "rpart", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_7G$results
##           cp  Accuracy      Kappa AccuracySD    KappaSD
## 1 0.04848485 0.5524231 0.10692105 0.04645894 0.09414045
## 2 0.05454545 0.5493928 0.10144561 0.04575070 0.09188355
## 3 0.18787879 0.5223708 0.04901466 0.03672728 0.07788091
smile__tree_model_7G$coefnames
## [1] "AU06_r_mean" "AU12_r_mean" "AU45_r_mean" "offset_mean"
varImp(smile__tree_model_7G)
## rpart variable importance
## 
##             Overall
## AU45_r_mean  100.00
## offset_mean   59.63
## AU06_r_mean   31.92
## AU12_r_mean    0.00
# summary(smile__tree_model_7G$finalModel)
fancyRpartPlot(smile__tree_model_7G$finalModel)

smile__tree_model_7G_pred <- predict(smile__tree_model_7G, tst_smile)
summary(smile__tree_model_7G_pred)
## spontaneous deliberate  
##          92          50
smile__tree_model_7G_confM <- confusionMatrix(
  smile__tree_model_7G_pred,
  tst_smile$smile_type
)
smile__tree_model_7G_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          46          46
##   deliberate           24          26
##                                           
##                Accuracy : 0.507           
##                  95% CI : (0.4219, 0.5919)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.53358         
##                                           
##                   Kappa : 0.0182          
##                                           
##  Mcnemar's Test P-Value : 0.01207         
##                                           
##             Sensitivity : 0.6571          
##             Specificity : 0.3611          
##          Pos Pred Value : 0.5000          
##          Neg Pred Value : 0.5200          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3239          
##    Detection Prevalence : 0.6479          
##       Balanced Accuracy : 0.5091          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_7G.1_pred <- predict(smile__tree_model_7G, tst_smile_boys)
summary(smile__tree_model_7G.1_pred)
## spontaneous deliberate  
##          49          28
smile__tree_model_7G.1_confM <- confusionMatrix(
  smile__tree_model_7G.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_7G.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          24          25
##   deliberate           13          15
##                                         
##                Accuracy : 0.5065        
##                  95% CI : (0.39, 0.6224)
##     No Information Rate : 0.5195        
##     P-Value [Acc > NIR] : 0.63425       
##                                         
##                   Kappa : 0.0234        
##                                         
##  Mcnemar's Test P-Value : 0.07435       
##                                         
##             Sensitivity : 0.6486        
##             Specificity : 0.3750        
##          Pos Pred Value : 0.4898        
##          Neg Pred Value : 0.5357        
##              Prevalence : 0.4805        
##          Detection Rate : 0.3117        
##    Detection Prevalence : 0.6364        
##       Balanced Accuracy : 0.5118        
##                                         
##        'Positive' Class : spontaneous   
## 
set.seed(1973)
smile__tree_model_7G.2_pred <- predict(smile__tree_model_7G, tst_smile_girls)
summary(smile__tree_model_7G.2_pred)
## spontaneous deliberate  
##          43          22
smile__tree_model_7G.2_confM <- confusionMatrix(
  smile__tree_model_7G.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_7G.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          22          21
##   deliberate           11          11
##                                          
##                Accuracy : 0.5077         
##                  95% CI : (0.3807, 0.634)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.5495         
##                                          
##                   Kappa : 0.0105         
##                                          
##  Mcnemar's Test P-Value : 0.1116         
##                                          
##             Sensitivity : 0.6667         
##             Specificity : 0.3438         
##          Pos Pred Value : 0.5116         
##          Neg Pred Value : 0.5000         
##              Prevalence : 0.5077         
##          Detection Rate : 0.3385         
##    Detection Prevalence : 0.6615         
##       Balanced Accuracy : 0.5052         
##                                          
##        'Positive' Class : spontaneous    
## 
# 7H dynamics and AU's selection
set.seed(1973)
smile__tree_model_7H <- train(smile_type ~ AU01_r_mean + AU09_r_mean +
  AU10_r_mean + AU25_r_mean + AU45_r_mean +
  onset_mean + apex_mean + offset_mean,
method = "rpart", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_7H$results
##           cp  Accuracy      Kappa AccuracySD   KappaSD
## 1 0.04242424 0.5425802 0.08849963 0.07231989 0.1450692
## 2 0.04545455 0.5424020 0.08399104 0.07351021 0.1485909
## 3 0.22424242 0.5255849 0.04429576 0.04913641 0.0997257
smile__tree_model_7H$coefnames
## [1] "AU01_r_mean" "AU09_r_mean" "AU10_r_mean" "AU25_r_mean" "AU45_r_mean"
## [6] "onset_mean"  "apex_mean"   "offset_mean"
varImp(smile__tree_model_7H)
## rpart variable importance
## 
##             Overall
## AU25_r_mean  100.00
## AU45_r_mean   90.39
## AU01_r_mean   85.32
## AU09_r_mean   72.27
## apex_mean     55.42
## AU10_r_mean   38.91
## onset_mean     0.00
## offset_mean    0.00
# summary(smile__tree_model_7H$finalModel)
fancyRpartPlot(smile__tree_model_7H$finalModel)

smile__tree_model_7H_pred <- predict(smile__tree_model_7H, tst_smile)
summary(smile__tree_model_7H_pred)
## spontaneous deliberate  
##          88          54
smile__tree_model_7H_confM <- confusionMatrix(
  smile__tree_model_7H_pred,
  tst_smile$smile_type
)
smile__tree_model_7H_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          49          39
##   deliberate           21          33
##                                           
##                Accuracy : 0.5775          
##                  95% CI : (0.4918, 0.6598)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.05517         
##                                           
##                   Kappa : 0.1578          
##                                           
##  Mcnemar's Test P-Value : 0.02819         
##                                           
##             Sensitivity : 0.7000          
##             Specificity : 0.4583          
##          Pos Pred Value : 0.5568          
##          Neg Pred Value : 0.6111          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3451          
##    Detection Prevalence : 0.6197          
##       Balanced Accuracy : 0.5792          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_7H.1_pred <- predict(smile__tree_model_7H, tst_smile_boys)
summary(smile__tree_model_7H.1_pred)
## spontaneous deliberate  
##          39          38
smile__tree_model_7H.1_confM <- confusionMatrix(
  smile__tree_model_7H.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_7H.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          22          17
##   deliberate           15          23
##                                           
##                Accuracy : 0.5844          
##                  95% CI : (0.4664, 0.6957)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.1523          
##                                           
##                   Kappa : 0.1693          
##                                           
##  Mcnemar's Test P-Value : 0.8597          
##                                           
##             Sensitivity : 0.5946          
##             Specificity : 0.5750          
##          Pos Pred Value : 0.5641          
##          Neg Pred Value : 0.6053          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2857          
##    Detection Prevalence : 0.5065          
##       Balanced Accuracy : 0.5848          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_7H.2_pred <- predict(smile__tree_model_7H, tst_smile_girls)
summary(smile__tree_model_7H.2_pred)
## spontaneous deliberate  
##          49          16
smile__tree_model_7H.2_confM <- confusionMatrix(
  smile__tree_model_7H.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_7H.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          27          22
##   deliberate            6          10
##                                           
##                Accuracy : 0.5692          
##                  95% CI : (0.4404, 0.6915)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.192728        
##                                           
##                   Kappa : 0.1317          
##                                           
##  Mcnemar's Test P-Value : 0.004586        
##                                           
##             Sensitivity : 0.8182          
##             Specificity : 0.3125          
##          Pos Pred Value : 0.5510          
##          Neg Pred Value : 0.6250          
##              Prevalence : 0.5077          
##          Detection Rate : 0.4154          
##    Detection Prevalence : 0.7538          
##       Balanced Accuracy : 0.5653          
##                                           
##        'Positive' Class : spontaneous     
## 
# 7I

set.seed(1973)
smile__tree_model_7I <- train(smile_type ~ AU01_r_mean + AU09_r_mean +
  AU10_r_mean + AU25_r_mean + AU45_r_mean +
  onset_mean,
method = "rpart", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_7I$results
##           cp  Accuracy      Kappa AccuracySD   KappaSD
## 1 0.03030303 0.5458890 0.09560258 0.06427069 0.1274249
## 2 0.04545455 0.5364305 0.07335263 0.07508962 0.1507522
## 3 0.22424242 0.5255849 0.04429576 0.04913641 0.0997257
smile__tree_model_7I$coefnames
## [1] "AU01_r_mean" "AU09_r_mean" "AU10_r_mean" "AU25_r_mean" "AU45_r_mean"
## [6] "onset_mean"
varImp(smile__tree_model_7I)
## rpart variable importance
## 
##             Overall
## AU25_r_mean  100.00
## AU45_r_mean   90.39
## AU01_r_mean   85.32
## AU10_r_mean   76.48
## AU09_r_mean   72.27
## onset_mean     0.00
# summary(smile__tree_model_7I$finalModel)
fancyRpartPlot(smile__tree_model_7I$finalModel)

smile__tree_model_7I_pred <- predict(smile__tree_model_7I, tst_smile)
summary(smile__tree_model_7I_pred)
## spontaneous deliberate  
##          89          53
smile__tree_model_7I_confM <- confusionMatrix(
  smile__tree_model_7I_pred,
  tst_smile$smile_type
)
smile__tree_model_7I_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          49          40
##   deliberate           21          32
##                                           
##                Accuracy : 0.5704          
##                  95% CI : (0.4847, 0.6531)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.07664         
##                                           
##                   Kappa : 0.1439          
##                                           
##  Mcnemar's Test P-Value : 0.02119         
##                                           
##             Sensitivity : 0.7000          
##             Specificity : 0.4444          
##          Pos Pred Value : 0.5506          
##          Neg Pred Value : 0.6038          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3451          
##    Detection Prevalence : 0.6268          
##       Balanced Accuracy : 0.5722          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_7I.1_pred <- predict(smile__tree_model_7I, tst_smile_boys)
summary(smile__tree_model_7I.1_pred)
## spontaneous deliberate  
##          41          36
smile__tree_model_7I.1_confM <- confusionMatrix(
  smile__tree_model_7I.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_7I.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          23          18
##   deliberate           14          22
##                                           
##                Accuracy : 0.5844          
##                  95% CI : (0.4664, 0.6957)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.1523          
##                                           
##                   Kappa : 0.1709          
##                                           
##  Mcnemar's Test P-Value : 0.5959          
##                                           
##             Sensitivity : 0.6216          
##             Specificity : 0.5500          
##          Pos Pred Value : 0.5610          
##          Neg Pred Value : 0.6111          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2987          
##    Detection Prevalence : 0.5325          
##       Balanced Accuracy : 0.5858          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_7I.2_pred <- predict(smile__tree_model_7I, tst_smile_girls)
summary(smile__tree_model_7I.2_pred)
## spontaneous deliberate  
##          48          17
smile__tree_model_7I.2_confM <- confusionMatrix(
  smile__tree_model_7I.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_7I.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          26          22
##   deliberate            7          10
##                                           
##                Accuracy : 0.5538          
##                  95% CI : (0.4253, 0.6773)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.26784         
##                                           
##                   Kappa : 0.1011          
##                                           
##  Mcnemar's Test P-Value : 0.00933         
##                                           
##             Sensitivity : 0.7879          
##             Specificity : 0.3125          
##          Pos Pred Value : 0.5417          
##          Neg Pred Value : 0.5882          
##              Prevalence : 0.5077          
##          Detection Rate : 0.4000          
##    Detection Prevalence : 0.7385          
##       Balanced Accuracy : 0.5502          
##                                           
##        'Positive' Class : spontaneous     
## 
# 7J apex

set.seed(1973)
smile__tree_model_7J <- train(smile_type ~ AU01_r_mean + AU09_r_mean +
  AU10_r_mean + AU25_r_mean + AU45_r_mean +
  apex_mean,
method = "rpart", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_7J$results
##           cp  Accuracy      Kappa AccuracySD   KappaSD
## 1 0.04242424 0.5454323 0.09550827 0.07304606 0.1452256
## 2 0.04545455 0.5393717 0.07923498 0.07276411 0.1460974
## 3 0.22424242 0.5255849 0.04429576 0.04913641 0.0997257
smile__tree_model_7J$coefnames
## [1] "AU01_r_mean" "AU09_r_mean" "AU10_r_mean" "AU25_r_mean" "AU45_r_mean"
## [6] "apex_mean"
varImp(smile__tree_model_7J)
## rpart variable importance
## 
##             Overall
## AU25_r_mean  100.00
## AU45_r_mean   84.27
## AU01_r_mean   75.97
## AU09_r_mean   54.61
## apex_mean     27.02
## AU10_r_mean    0.00
# summary(smile__tree_model_7J$finalModel)
fancyRpartPlot(smile__tree_model_7J$finalModel)

smile__tree_model_7J_pred <- predict(smile__tree_model_7J, tst_smile)
summary(smile__tree_model_7J_pred)
## spontaneous deliberate  
##          88          54
smile__tree_model_7J_confM <- confusionMatrix(
  smile__tree_model_7J_pred,
  tst_smile$smile_type
)
smile__tree_model_7J_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          49          39
##   deliberate           21          33
##                                           
##                Accuracy : 0.5775          
##                  95% CI : (0.4918, 0.6598)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.05517         
##                                           
##                   Kappa : 0.1578          
##                                           
##  Mcnemar's Test P-Value : 0.02819         
##                                           
##             Sensitivity : 0.7000          
##             Specificity : 0.4583          
##          Pos Pred Value : 0.5568          
##          Neg Pred Value : 0.6111          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3451          
##    Detection Prevalence : 0.6197          
##       Balanced Accuracy : 0.5792          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_7J.1_pred <- predict(smile__tree_model_7J, tst_smile_boys)
summary(smile__tree_model_7J.1_pred)
## spontaneous deliberate  
##          39          38
smile__tree_model_7J.1_confM <- confusionMatrix(
  smile__tree_model_7J.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_7J.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          22          17
##   deliberate           15          23
##                                           
##                Accuracy : 0.5844          
##                  95% CI : (0.4664, 0.6957)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.1523          
##                                           
##                   Kappa : 0.1693          
##                                           
##  Mcnemar's Test P-Value : 0.8597          
##                                           
##             Sensitivity : 0.5946          
##             Specificity : 0.5750          
##          Pos Pred Value : 0.5641          
##          Neg Pred Value : 0.6053          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2857          
##    Detection Prevalence : 0.5065          
##       Balanced Accuracy : 0.5848          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_7J.2_pred <- predict(smile__tree_model_7J, tst_smile_girls)
summary(smile__tree_model_7J.2_pred)
## spontaneous deliberate  
##          49          16
smile__tree_model_7J.2_confM <- confusionMatrix(
  smile__tree_model_7J.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_7J.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          27          22
##   deliberate            6          10
##                                           
##                Accuracy : 0.5692          
##                  95% CI : (0.4404, 0.6915)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.192728        
##                                           
##                   Kappa : 0.1317          
##                                           
##  Mcnemar's Test P-Value : 0.004586        
##                                           
##             Sensitivity : 0.8182          
##             Specificity : 0.3125          
##          Pos Pred Value : 0.5510          
##          Neg Pred Value : 0.6250          
##              Prevalence : 0.5077          
##          Detection Rate : 0.4154          
##    Detection Prevalence : 0.7538          
##       Balanced Accuracy : 0.5653          
##                                           
##        'Positive' Class : spontaneous     
## 
# 7K

set.seed(1973)
smile__tree_model_7K <- train(smile_type ~ AU01_r_mean + AU09_r_mean +
  AU10_r_mean + AU25_r_mean + AU45_r_mean +
  offset_mean,
method = "rpart", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_7K$results
##           cp  Accuracy      Kappa AccuracySD   KappaSD
## 1 0.03030303 0.5548017 0.11382011 0.08030484 0.1597152
## 2 0.04545455 0.5334893 0.06747028 0.07339185 0.1473916
## 3 0.22424242 0.5255849 0.04429576 0.04913641 0.0997257
smile__tree_model_7K$coefnames
## [1] "AU01_r_mean" "AU09_r_mean" "AU10_r_mean" "AU25_r_mean" "AU45_r_mean"
## [6] "offset_mean"
varImp(smile__tree_model_7K)
## rpart variable importance
## 
##             Overall
## AU25_r_mean  100.00
## AU45_r_mean   90.39
## AU01_r_mean   85.32
## AU10_r_mean   76.48
## AU09_r_mean   72.27
## offset_mean    0.00
# summary(smile__tree_model_7K$finalModel)
fancyRpartPlot(smile__tree_model_7K$finalModel)

smile__tree_model_7K_pred <- predict(smile__tree_model_7K, tst_smile)
summary(smile__tree_model_7K_pred)
## spontaneous deliberate  
##          89          53
smile__tree_model_7K_confM <- confusionMatrix(
  smile__tree_model_7K_pred,
  tst_smile$smile_type
)
smile__tree_model_7K_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          49          40
##   deliberate           21          32
##                                           
##                Accuracy : 0.5704          
##                  95% CI : (0.4847, 0.6531)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.07664         
##                                           
##                   Kappa : 0.1439          
##                                           
##  Mcnemar's Test P-Value : 0.02119         
##                                           
##             Sensitivity : 0.7000          
##             Specificity : 0.4444          
##          Pos Pred Value : 0.5506          
##          Neg Pred Value : 0.6038          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3451          
##    Detection Prevalence : 0.6268          
##       Balanced Accuracy : 0.5722          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_7K.1_pred <- predict(smile__tree_model_7K, tst_smile_boys)
summary(smile__tree_model_7K.1_pred)
## spontaneous deliberate  
##          41          36
smile__tree_model_7K.1_confM <- confusionMatrix(
  smile__tree_model_7K.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_7K.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          23          18
##   deliberate           14          22
##                                           
##                Accuracy : 0.5844          
##                  95% CI : (0.4664, 0.6957)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.1523          
##                                           
##                   Kappa : 0.1709          
##                                           
##  Mcnemar's Test P-Value : 0.5959          
##                                           
##             Sensitivity : 0.6216          
##             Specificity : 0.5500          
##          Pos Pred Value : 0.5610          
##          Neg Pred Value : 0.6111          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2987          
##    Detection Prevalence : 0.5325          
##       Balanced Accuracy : 0.5858          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_7K.2_pred <- predict(smile__tree_model_7K, tst_smile_girls)
summary(smile__tree_model_7K.2_pred)
## spontaneous deliberate  
##          48          17
smile__tree_model_7K.2_confM <- confusionMatrix(
  smile__tree_model_7K.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_7K.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          26          22
##   deliberate            7          10
##                                           
##                Accuracy : 0.5538          
##                  95% CI : (0.4253, 0.6773)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.26784         
##                                           
##                   Kappa : 0.1011          
##                                           
##  Mcnemar's Test P-Value : 0.00933         
##                                           
##             Sensitivity : 0.7879          
##             Specificity : 0.3125          
##          Pos Pred Value : 0.5417          
##          Neg Pred Value : 0.5882          
##              Prevalence : 0.5077          
##          Detection Rate : 0.4000          
##    Detection Prevalence : 0.7385          
##       Balanced Accuracy : 0.5502          
##                                           
##        'Positive' Class : spontaneous     
## 
# 8 strongest feature combination

# 8A
set.seed(1973)
smile__tree_model_8A <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + onset_mean + apex_mean +
  offset_mean + lip_mean + eye_mean,
method = "rpart", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_8A$results
##           cp  Accuracy      Kappa AccuracySD    KappaSD
## 1 0.03636364 0.5645443 0.13035315 0.04265332 0.08444669
## 2 0.05454545 0.5464516 0.09393859 0.04163563 0.08371676
## 3 0.18787879 0.5076649 0.01960290 0.05893775 0.12183508
smile__tree_model_8A$coefnames
## [1] "AU06_r_mean" "AU12_r_mean" "AU45_r_mean" "onset_mean"  "apex_mean"  
## [6] "offset_mean" "lip_mean"    "eye_mean"
varImp(smile__tree_model_8A)
## rpart variable importance
## 
##             Overall
## AU45_r_mean  100.00
## offset_mean   69.75
## eye_mean      69.12
## AU06_r_mean   48.99
## onset_mean    26.75
## apex_mean     21.60
## AU12_r_mean    0.00
## lip_mean       0.00
# summary(smile__tree_model_8A$finalModel)
fancyRpartPlot(smile__tree_model_8A$finalModel)

smile__tree_model_8A_pred <- predict(smile__tree_model_8A, tst_smile)
summary(smile__tree_model_8A_pred)
## spontaneous deliberate  
##          92          50
smile__tree_model_8A_confM <- confusionMatrix(
  smile__tree_model_8A_pred,
  tst_smile$smile_type
)
smile__tree_model_8A_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          46          46
##   deliberate           24          26
##                                           
##                Accuracy : 0.507           
##                  95% CI : (0.4219, 0.5919)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.53358         
##                                           
##                   Kappa : 0.0182          
##                                           
##  Mcnemar's Test P-Value : 0.01207         
##                                           
##             Sensitivity : 0.6571          
##             Specificity : 0.3611          
##          Pos Pred Value : 0.5000          
##          Neg Pred Value : 0.5200          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3239          
##    Detection Prevalence : 0.6479          
##       Balanced Accuracy : 0.5091          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_8A.1_pred <- predict(smile__tree_model_8A, tst_smile_boys)
summary(smile__tree_model_8A.1_pred)
## spontaneous deliberate  
##          49          28
smile__tree_model_8A.1_confM <- confusionMatrix(
  smile__tree_model_8A.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_8A.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          24          25
##   deliberate           13          15
##                                         
##                Accuracy : 0.5065        
##                  95% CI : (0.39, 0.6224)
##     No Information Rate : 0.5195        
##     P-Value [Acc > NIR] : 0.63425       
##                                         
##                   Kappa : 0.0234        
##                                         
##  Mcnemar's Test P-Value : 0.07435       
##                                         
##             Sensitivity : 0.6486        
##             Specificity : 0.3750        
##          Pos Pred Value : 0.4898        
##          Neg Pred Value : 0.5357        
##              Prevalence : 0.4805        
##          Detection Rate : 0.3117        
##    Detection Prevalence : 0.6364        
##       Balanced Accuracy : 0.5118        
##                                         
##        'Positive' Class : spontaneous   
## 
set.seed(1973)
smile__tree_model_8A.2_pred <- predict(smile__tree_model_8A, tst_smile_girls)
summary(smile__tree_model_8A.2_pred)
## spontaneous deliberate  
##          43          22
smile__tree_model_8A.2_confM <- confusionMatrix(
  smile__tree_model_8A.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_8A.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          22          21
##   deliberate           11          11
##                                          
##                Accuracy : 0.5077         
##                  95% CI : (0.3807, 0.634)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.5495         
##                                          
##                   Kappa : 0.0105         
##                                          
##  Mcnemar's Test P-Value : 0.1116         
##                                          
##             Sensitivity : 0.6667         
##             Specificity : 0.3438         
##          Pos Pred Value : 0.5116         
##          Neg Pred Value : 0.5000         
##              Prevalence : 0.5077         
##          Detection Rate : 0.3385         
##    Detection Prevalence : 0.6615         
##       Balanced Accuracy : 0.5052         
##                                          
##        'Positive' Class : spontaneous    
## 
# 8B
set.seed(1973)
smile__tree_model_8B <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + onset_mean + lip_mean + eye_mean,
method = "rpart", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_8B$results
##           cp  Accuracy      Kappa AccuracySD    KappaSD
## 1 0.03636364 0.5707832 0.14212731 0.03047154 0.06075247
## 2 0.06060606 0.5435105 0.09129408 0.03933110 0.08035001
## 3 0.18787879 0.5076649 0.01960290 0.05893775 0.12183508
smile__tree_model_8B$coefnames
## [1] "AU06_r_mean" "AU12_r_mean" "AU45_r_mean" "onset_mean"  "lip_mean"   
## [6] "eye_mean"
varImp(smile__tree_model_8B)
## rpart variable importance
## 
##             Overall
## AU45_r_mean  100.00
## eye_mean      69.12
## AU06_r_mean   48.99
## onset_mean    46.87
## lip_mean      27.55
## AU12_r_mean    0.00
# summary(smile__tree_model_8B$finalModel)
fancyRpartPlot(smile__tree_model_8B$finalModel)

smile__tree_model_8B_pred <- predict(smile__tree_model_8B, tst_smile)
summary(smile__tree_model_8B_pred)
## spontaneous deliberate  
##          85          57
smile__tree_model_8B_confM <- confusionMatrix(
  smile__tree_model_8B_pred,
  tst_smile$smile_type
)
smile__tree_model_8B_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          44          41
##   deliberate           26          31
##                                           
##                Accuracy : 0.5282          
##                  95% CI : (0.4427, 0.6124)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.3376          
##                                           
##                   Kappa : 0.059           
##                                           
##  Mcnemar's Test P-Value : 0.0872          
##                                           
##             Sensitivity : 0.6286          
##             Specificity : 0.4306          
##          Pos Pred Value : 0.5176          
##          Neg Pred Value : 0.5439          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3099          
##    Detection Prevalence : 0.5986          
##       Balanced Accuracy : 0.5296          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_8B.1_pred <- predict(smile__tree_model_8B, tst_smile_boys)
summary(smile__tree_model_8B.1_pred)
## spontaneous deliberate  
##          45          32
smile__tree_model_8B.1_confM <- confusionMatrix(
  smile__tree_model_8B.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_8B.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          23          22
##   deliberate           14          18
##                                           
##                Accuracy : 0.5325          
##                  95% CI : (0.4152, 0.6471)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.4552          
##                                           
##                   Kappa : 0.071           
##                                           
##  Mcnemar's Test P-Value : 0.2433          
##                                           
##             Sensitivity : 0.6216          
##             Specificity : 0.4500          
##          Pos Pred Value : 0.5111          
##          Neg Pred Value : 0.5625          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2987          
##    Detection Prevalence : 0.5844          
##       Balanced Accuracy : 0.5358          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_8B.2_pred <- predict(smile__tree_model_8B, tst_smile_girls)
summary(smile__tree_model_8B.2_pred)
## spontaneous deliberate  
##          40          25
smile__tree_model_8B.2_confM <- confusionMatrix(
  smile__tree_model_8B.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_8B.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          21          19
##   deliberate           12          13
##                                           
##                Accuracy : 0.5231          
##                  95% CI : (0.3954, 0.6485)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.4510          
##                                           
##                   Kappa : 0.0428          
##                                           
##  Mcnemar's Test P-Value : 0.2812          
##                                           
##             Sensitivity : 0.6364          
##             Specificity : 0.4062          
##          Pos Pred Value : 0.5250          
##          Neg Pred Value : 0.5200          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3231          
##    Detection Prevalence : 0.6154          
##       Balanced Accuracy : 0.5213          
##                                           
##        'Positive' Class : spontaneous     
## 
# 8C
set.seed(1973)
smile__tree_model_8C <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + apex_mean + lip_mean + eye_mean,
method = "rpart", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_8C$results
##           cp  Accuracy      Kappa AccuracySD    KappaSD
## 1 0.04242424 0.5646335 0.13053791 0.02257622 0.04670496
## 2 0.06060606 0.5435105 0.09129408 0.03933110 0.08035001
## 3 0.18787879 0.5076649 0.01960290 0.05893775 0.12183508
smile__tree_model_8C$coefnames
## [1] "AU06_r_mean" "AU12_r_mean" "AU45_r_mean" "apex_mean"   "lip_mean"   
## [6] "eye_mean"
varImp(smile__tree_model_8C)
## rpart variable importance
## 
##             Overall
## AU45_r_mean  100.00
## eye_mean      69.12
## AU06_r_mean   48.99
## apex_mean     39.60
## lip_mean      27.55
## AU12_r_mean    0.00
# summary(smile__tree_model_8C$finalModel)
fancyRpartPlot(smile__tree_model_8C$finalModel)

smile__tree_model_8C_pred <- predict(smile__tree_model_8C, tst_smile)
summary(smile__tree_model_8C_pred)
## spontaneous deliberate  
##          85          57
smile__tree_model_8C_confM <- confusionMatrix(
  smile__tree_model_8C_pred,
  tst_smile$smile_type
)
smile__tree_model_8C_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          44          41
##   deliberate           26          31
##                                           
##                Accuracy : 0.5282          
##                  95% CI : (0.4427, 0.6124)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.3376          
##                                           
##                   Kappa : 0.059           
##                                           
##  Mcnemar's Test P-Value : 0.0872          
##                                           
##             Sensitivity : 0.6286          
##             Specificity : 0.4306          
##          Pos Pred Value : 0.5176          
##          Neg Pred Value : 0.5439          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3099          
##    Detection Prevalence : 0.5986          
##       Balanced Accuracy : 0.5296          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_8C.1_pred <- predict(smile__tree_model_8C, tst_smile_boys)
summary(smile__tree_model_8C.1_pred)
## spontaneous deliberate  
##          45          32
smile__tree_model_8C.1_confM <- confusionMatrix(
  smile__tree_model_8C.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_8C.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          23          22
##   deliberate           14          18
##                                           
##                Accuracy : 0.5325          
##                  95% CI : (0.4152, 0.6471)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.4552          
##                                           
##                   Kappa : 0.071           
##                                           
##  Mcnemar's Test P-Value : 0.2433          
##                                           
##             Sensitivity : 0.6216          
##             Specificity : 0.4500          
##          Pos Pred Value : 0.5111          
##          Neg Pred Value : 0.5625          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2987          
##    Detection Prevalence : 0.5844          
##       Balanced Accuracy : 0.5358          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_8C.2_pred <- predict(smile__tree_model_8C, tst_smile_girls)
summary(smile__tree_model_8C.2_pred)
## spontaneous deliberate  
##          40          25
smile__tree_model_8C.2_confM <- confusionMatrix(
  smile__tree_model_8C.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_8C.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          21          19
##   deliberate           12          13
##                                           
##                Accuracy : 0.5231          
##                  95% CI : (0.3954, 0.6485)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.4510          
##                                           
##                   Kappa : 0.0428          
##                                           
##  Mcnemar's Test P-Value : 0.2812          
##                                           
##             Sensitivity : 0.6364          
##             Specificity : 0.4062          
##          Pos Pred Value : 0.5250          
##          Neg Pred Value : 0.5200          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3231          
##    Detection Prevalence : 0.6154          
##       Balanced Accuracy : 0.5213          
##                                           
##        'Positive' Class : spontaneous     
## 
# 8D
set.seed(1973)
smile__tree_model_8D <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + offset_mean + lip_mean +
  eye_mean,
method = "rpart", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_8D$results
##           cp  Accuracy     Kappa AccuracySD    KappaSD
## 1 0.04848485 0.5525123 0.1060044 0.04568814 0.09216566
## 2 0.05454545 0.5525123 0.1060044 0.04568814 0.09216566
## 3 0.18787879 0.5076649 0.0196029 0.05893775 0.12183508
smile__tree_model_8D$coefnames
## [1] "AU06_r_mean" "AU12_r_mean" "AU45_r_mean" "offset_mean" "lip_mean"   
## [6] "eye_mean"
varImp(smile__tree_model_8D)
## rpart variable importance
## 
##             Overall
## AU45_r_mean  100.00
## eye_mean      66.67
## offset_mean   50.87
## AU06_r_mean   38.96
## lip_mean      19.35
## AU12_r_mean    0.00
# summary(smile__tree_model_8D$finalModel)
fancyRpartPlot(smile__tree_model_8D$finalModel)

smile__tree_model_8D_pred <- predict(smile__tree_model_8D, tst_smile)
summary(smile__tree_model_8D_pred)
## spontaneous deliberate  
##         102          40
smile__tree_model_8D_confM <- confusionMatrix(
  smile__tree_model_8D_pred,
  tst_smile$smile_type
)
smile__tree_model_8D_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          52          50
##   deliberate           18          22
##                                           
##                Accuracy : 0.5211          
##                  95% CI : (0.4358, 0.6056)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.4008030       
##                                           
##                   Kappa : 0.0481          
##                                           
##  Mcnemar's Test P-Value : 0.0001704       
##                                           
##             Sensitivity : 0.7429          
##             Specificity : 0.3056          
##          Pos Pred Value : 0.5098          
##          Neg Pred Value : 0.5500          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3662          
##    Detection Prevalence : 0.7183          
##       Balanced Accuracy : 0.5242          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_8D.1_pred <- predict(smile__tree_model_8D, tst_smile_boys)
summary(smile__tree_model_8D.1_pred)
## spontaneous deliberate  
##          54          23
smile__tree_model_8D.1_confM <- confusionMatrix(
  smile__tree_model_8D.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_8D.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          27          27
##   deliberate           10          13
##                                           
##                Accuracy : 0.5195          
##                  95% CI : (0.4026, 0.6348)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.545933        
##                                           
##                   Kappa : 0.0538          
##                                           
##  Mcnemar's Test P-Value : 0.008529        
##                                           
##             Sensitivity : 0.7297          
##             Specificity : 0.3250          
##          Pos Pred Value : 0.5000          
##          Neg Pred Value : 0.5652          
##              Prevalence : 0.4805          
##          Detection Rate : 0.3506          
##    Detection Prevalence : 0.7013          
##       Balanced Accuracy : 0.5274          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_8D.2_pred <- predict(smile__tree_model_8D, tst_smile_girls)
summary(smile__tree_model_8D.2_pred)
## spontaneous deliberate  
##          48          17
smile__tree_model_8D.2_confM <- confusionMatrix(
  smile__tree_model_8D.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_8D.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          25          23
##   deliberate            8           9
##                                           
##                Accuracy : 0.5231          
##                  95% CI : (0.3954, 0.6485)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.45095         
##                                           
##                   Kappa : 0.0391          
##                                           
##  Mcnemar's Test P-Value : 0.01192         
##                                           
##             Sensitivity : 0.7576          
##             Specificity : 0.2812          
##          Pos Pred Value : 0.5208          
##          Neg Pred Value : 0.5294          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3846          
##    Detection Prevalence : 0.7385          
##       Balanced Accuracy : 0.5194          
##                                           
##        'Positive' Class : spontaneous     
## 
# 8E
set.seed(1973)
smile__tree_model_8E <- train(smile_type ~ AU01_r_mean + AU09_r_mean +
  AU10_r_mean + AU25_r_mean + AU45_r_mean +
  onset_mean + apex_mean + offset_mean + lip_mean +
  eye_mean,
method = "rpart", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_8E$results
##           cp  Accuracy      Kappa AccuracySD   KappaSD
## 1 0.04242424 0.5335784 0.06951700 0.06719129 0.1351431
## 2 0.04545455 0.5394608 0.08128171 0.06932694 0.1391696
## 3 0.22424242 0.5255849 0.04429576 0.04913641 0.0997257
smile__tree_model_8E$coefnames
##  [1] "AU01_r_mean" "AU09_r_mean" "AU10_r_mean" "AU25_r_mean" "AU45_r_mean"
##  [6] "onset_mean"  "apex_mean"   "offset_mean" "lip_mean"    "eye_mean"
varImp(smile__tree_model_8E)
## rpart variable importance
## 
##             Overall
## AU10_r_mean  100.00
## AU25_r_mean   92.60
## AU45_r_mean   82.12
## AU09_r_mean   62.58
## AU01_r_mean   60.90
## eye_mean       0.00
## lip_mean       0.00
## onset_mean     0.00
## apex_mean      0.00
## offset_mean    0.00
# summary(smile__tree_model_8E$finalModel)
fancyRpartPlot(smile__tree_model_8E$finalModel)

smile__tree_model_8E_pred <- predict(smile__tree_model_8E, tst_smile)
summary(smile__tree_model_8E_pred)
## spontaneous deliberate  
##          41         101
smile__tree_model_8E_confM <- confusionMatrix(
  smile__tree_model_8E_pred,
  tst_smile$smile_type
)
smile__tree_model_8E_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          22          19
##   deliberate           48          53
##                                           
##                Accuracy : 0.5282          
##                  95% CI : (0.4427, 0.6124)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.3375712       
##                                           
##                   Kappa : 0.0507          
##                                           
##  Mcnemar's Test P-Value : 0.0006245       
##                                           
##             Sensitivity : 0.3143          
##             Specificity : 0.7361          
##          Pos Pred Value : 0.5366          
##          Neg Pred Value : 0.5248          
##              Prevalence : 0.4930          
##          Detection Rate : 0.1549          
##    Detection Prevalence : 0.2887          
##       Balanced Accuracy : 0.5252          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_8E.1_pred <- predict(smile__tree_model_8E, tst_smile_boys)
summary(smile__tree_model_8E.1_pred)
## spontaneous deliberate  
##          13          64
smile__tree_model_8E.1_confM <- confusionMatrix(
  smile__tree_model_8E.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_8E.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           9           4
##   deliberate           28          36
##                                           
##                Accuracy : 0.5844          
##                  95% CI : (0.4664, 0.6957)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.1523          
##                                           
##                   Kappa : 0.1468          
##                                           
##  Mcnemar's Test P-Value : 4.785e-05       
##                                           
##             Sensitivity : 0.2432          
##             Specificity : 0.9000          
##          Pos Pred Value : 0.6923          
##          Neg Pred Value : 0.5625          
##              Prevalence : 0.4805          
##          Detection Rate : 0.1169          
##    Detection Prevalence : 0.1688          
##       Balanced Accuracy : 0.5716          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_8E.2_pred <- predict(smile__tree_model_8E, tst_smile_girls)
summary(smile__tree_model_8E.2_pred)
## spontaneous deliberate  
##          28          37
smile__tree_model_8E.2_confM <- confusionMatrix(
  smile__tree_model_8E.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_8E.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          13          15
##   deliberate           20          17
##                                          
##                Accuracy : 0.4615         
##                  95% CI : (0.337, 0.5897)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.8074         
##                                          
##                   Kappa : -0.0746        
##                                          
##  Mcnemar's Test P-Value : 0.4990         
##                                          
##             Sensitivity : 0.3939         
##             Specificity : 0.5312         
##          Pos Pred Value : 0.4643         
##          Neg Pred Value : 0.4595         
##              Prevalence : 0.5077         
##          Detection Rate : 0.2000         
##    Detection Prevalence : 0.4308         
##       Balanced Accuracy : 0.4626         
##                                          
##        'Positive' Class : spontaneous    
## 
# 8F
set.seed(1973)
smile__tree_model_8F <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + onset_mean + apex_mean +
  offset_mean + eye_mean,
method = "rpart", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_8F$results
##           cp  Accuracy      Kappa AccuracySD    KappaSD
## 1 0.03636364 0.5584837 0.11790741 0.03491922 0.06900019
## 2 0.05454545 0.5464516 0.09393859 0.04163563 0.08371676
## 3 0.18787879 0.5076649 0.01960290 0.05893775 0.12183508
smile__tree_model_8F$coefnames
## [1] "AU06_r_mean" "AU12_r_mean" "AU45_r_mean" "onset_mean"  "apex_mean"  
## [6] "offset_mean" "eye_mean"
varImp(smile__tree_model_8F)
## rpart variable importance
## 
##             Overall
## AU45_r_mean  100.00
## offset_mean   69.75
## eye_mean      69.12
## AU06_r_mean   48.99
## onset_mean    26.75
## apex_mean     21.60
## AU12_r_mean    0.00
# summary(smile__tree_model_8F$finalModel)
fancyRpartPlot(smile__tree_model_8F$finalModel)

smile__tree_model_8F_pred <- predict(smile__tree_model_8F, tst_smile)
summary(smile__tree_model_8F_pred)
## spontaneous deliberate  
##          92          50
smile__tree_model_8F_confM <- confusionMatrix(
  smile__tree_model_8F_pred,
  tst_smile$smile_type
)
smile__tree_model_8F_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          46          46
##   deliberate           24          26
##                                           
##                Accuracy : 0.507           
##                  95% CI : (0.4219, 0.5919)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.53358         
##                                           
##                   Kappa : 0.0182          
##                                           
##  Mcnemar's Test P-Value : 0.01207         
##                                           
##             Sensitivity : 0.6571          
##             Specificity : 0.3611          
##          Pos Pred Value : 0.5000          
##          Neg Pred Value : 0.5200          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3239          
##    Detection Prevalence : 0.6479          
##       Balanced Accuracy : 0.5091          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_8F.1_pred <- predict(smile__tree_model_8F, tst_smile_boys)
summary(smile__tree_model_8F.1_pred)
## spontaneous deliberate  
##          49          28
smile__tree_model_8F.1_confM <- confusionMatrix(
  smile__tree_model_8F.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_8F.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          24          25
##   deliberate           13          15
##                                         
##                Accuracy : 0.5065        
##                  95% CI : (0.39, 0.6224)
##     No Information Rate : 0.5195        
##     P-Value [Acc > NIR] : 0.63425       
##                                         
##                   Kappa : 0.0234        
##                                         
##  Mcnemar's Test P-Value : 0.07435       
##                                         
##             Sensitivity : 0.6486        
##             Specificity : 0.3750        
##          Pos Pred Value : 0.4898        
##          Neg Pred Value : 0.5357        
##              Prevalence : 0.4805        
##          Detection Rate : 0.3117        
##    Detection Prevalence : 0.6364        
##       Balanced Accuracy : 0.5118        
##                                         
##        'Positive' Class : spontaneous   
## 
set.seed(1973)
smile__tree_model_8F.2_pred <- predict(smile__tree_model_8F, tst_smile_girls)
summary(smile__tree_model_8F.2_pred)
## spontaneous deliberate  
##          43          22
smile__tree_model_8F.2_confM <- confusionMatrix(
  smile__tree_model_8F.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_8F.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          22          21
##   deliberate           11          11
##                                          
##                Accuracy : 0.5077         
##                  95% CI : (0.3807, 0.634)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.5495         
##                                          
##                   Kappa : 0.0105         
##                                          
##  Mcnemar's Test P-Value : 0.1116         
##                                          
##             Sensitivity : 0.6667         
##             Specificity : 0.3438         
##          Pos Pred Value : 0.5116         
##          Neg Pred Value : 0.5000         
##              Prevalence : 0.5077         
##          Detection Rate : 0.3385         
##    Detection Prevalence : 0.6615         
##       Balanced Accuracy : 0.5052         
##                                          
##        'Positive' Class : spontaneous    
## 
# 8G
set.seed(1973)
smile__tree_model_8G <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + onset_mean + eye_mean,
method = "rpart", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_8G$results
##           cp  Accuracy      Kappa AccuracySD    KappaSD
## 1 0.03636364 0.5617814 0.12318742 0.03094505 0.06127823
## 2 0.06060606 0.5435105 0.09129408 0.03933110 0.08035001
## 3 0.18787879 0.5076649 0.01960290 0.05893775 0.12183508
smile__tree_model_8G$coefnames
## [1] "AU06_r_mean" "AU12_r_mean" "AU45_r_mean" "onset_mean"  "eye_mean"
varImp(smile__tree_model_8G)
## rpart variable importance
## 
##             Overall
## AU45_r_mean  100.00
## eye_mean      58.79
## AU06_r_mean   31.92
## onset_mean    29.09
## AU12_r_mean    0.00
# summary(smile__tree_model_8G$finalModel)
fancyRpartPlot(smile__tree_model_8G$finalModel)

smile__tree_model_8G_pred <- predict(smile__tree_model_8G, tst_smile)
summary(smile__tree_model_8G_pred)
## spontaneous deliberate  
##          85          57
smile__tree_model_8G_confM <- confusionMatrix(
  smile__tree_model_8G_pred,
  tst_smile$smile_type
)
smile__tree_model_8G_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          44          41
##   deliberate           26          31
##                                           
##                Accuracy : 0.5282          
##                  95% CI : (0.4427, 0.6124)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.3376          
##                                           
##                   Kappa : 0.059           
##                                           
##  Mcnemar's Test P-Value : 0.0872          
##                                           
##             Sensitivity : 0.6286          
##             Specificity : 0.4306          
##          Pos Pred Value : 0.5176          
##          Neg Pred Value : 0.5439          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3099          
##    Detection Prevalence : 0.5986          
##       Balanced Accuracy : 0.5296          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_8G.1_pred <- predict(smile__tree_model_8G, tst_smile_boys)
summary(smile__tree_model_8G.1_pred)
## spontaneous deliberate  
##          45          32
smile__tree_model_8G.1_confM <- confusionMatrix(
  smile__tree_model_8G.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_8G.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          23          22
##   deliberate           14          18
##                                           
##                Accuracy : 0.5325          
##                  95% CI : (0.4152, 0.6471)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.4552          
##                                           
##                   Kappa : 0.071           
##                                           
##  Mcnemar's Test P-Value : 0.2433          
##                                           
##             Sensitivity : 0.6216          
##             Specificity : 0.4500          
##          Pos Pred Value : 0.5111          
##          Neg Pred Value : 0.5625          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2987          
##    Detection Prevalence : 0.5844          
##       Balanced Accuracy : 0.5358          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_8G.2_pred <- predict(smile__tree_model_8G, tst_smile_girls)
summary(smile__tree_model_8G.2_pred)
## spontaneous deliberate  
##          40          25
smile__tree_model_8G.2_confM <- confusionMatrix(
  smile__tree_model_8G.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_8G.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          21          19
##   deliberate           12          13
##                                           
##                Accuracy : 0.5231          
##                  95% CI : (0.3954, 0.6485)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.4510          
##                                           
##                   Kappa : 0.0428          
##                                           
##  Mcnemar's Test P-Value : 0.2812          
##                                           
##             Sensitivity : 0.6364          
##             Specificity : 0.4062          
##          Pos Pred Value : 0.5250          
##          Neg Pred Value : 0.5200          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3231          
##    Detection Prevalence : 0.6154          
##       Balanced Accuracy : 0.5213          
##                                           
##        'Positive' Class : spontaneous     
## 
# 8H apex
set.seed(1973)
smile__tree_model_8H <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + apex_mean + eye_mean,
method = "rpart", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_8H$results
##           cp  Accuracy      Kappa AccuracySD    KappaSD
## 1 0.04242424 0.5647226 0.12902381 0.03522295 0.07058369
## 2 0.06060606 0.5435105 0.09129408 0.03933110 0.08035001
## 3 0.18787879 0.5076649 0.01960290 0.05893775 0.12183508
smile__tree_model_8H$coefnames
## [1] "AU06_r_mean" "AU12_r_mean" "AU45_r_mean" "apex_mean"   "eye_mean"
varImp(smile__tree_model_8H)
## rpart variable importance
## 
##             Overall
## AU45_r_mean  100.00
## eye_mean      58.79
## AU06_r_mean   31.92
## apex_mean     19.39
## AU12_r_mean    0.00
# summary(smile__tree_model_8H$finalModel)
fancyRpartPlot(smile__tree_model_8H$finalModel)

smile__tree_model_8H_pred <- predict(smile__tree_model_8H, tst_smile)
summary(smile__tree_model_8H_pred)
## spontaneous deliberate  
##          85          57
smile__tree_model_8H_confM <- confusionMatrix(
  smile__tree_model_8H_pred,
  tst_smile$smile_type
)
smile__tree_model_8H_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          44          41
##   deliberate           26          31
##                                           
##                Accuracy : 0.5282          
##                  95% CI : (0.4427, 0.6124)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.3376          
##                                           
##                   Kappa : 0.059           
##                                           
##  Mcnemar's Test P-Value : 0.0872          
##                                           
##             Sensitivity : 0.6286          
##             Specificity : 0.4306          
##          Pos Pred Value : 0.5176          
##          Neg Pred Value : 0.5439          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3099          
##    Detection Prevalence : 0.5986          
##       Balanced Accuracy : 0.5296          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_8H.1_pred <- predict(smile__tree_model_8H, tst_smile_boys)
summary(smile__tree_model_8H.1_pred)
## spontaneous deliberate  
##          45          32
smile__tree_model_8H.1_confM <- confusionMatrix(
  smile__tree_model_8H.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_8H.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          23          22
##   deliberate           14          18
##                                           
##                Accuracy : 0.5325          
##                  95% CI : (0.4152, 0.6471)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.4552          
##                                           
##                   Kappa : 0.071           
##                                           
##  Mcnemar's Test P-Value : 0.2433          
##                                           
##             Sensitivity : 0.6216          
##             Specificity : 0.4500          
##          Pos Pred Value : 0.5111          
##          Neg Pred Value : 0.5625          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2987          
##    Detection Prevalence : 0.5844          
##       Balanced Accuracy : 0.5358          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__tree_model_8H.2_pred <- predict(smile__tree_model_8H, tst_smile_girls)
summary(smile__tree_model_8H.2_pred)
## spontaneous deliberate  
##          40          25
smile__tree_model_8H.2_confM <- confusionMatrix(
  smile__tree_model_8H.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_8H.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          21          19
##   deliberate           12          13
##                                           
##                Accuracy : 0.5231          
##                  95% CI : (0.3954, 0.6485)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.4510          
##                                           
##                   Kappa : 0.0428          
##                                           
##  Mcnemar's Test P-Value : 0.2812          
##                                           
##             Sensitivity : 0.6364          
##             Specificity : 0.4062          
##          Pos Pred Value : 0.5250          
##          Neg Pred Value : 0.5200          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3231          
##    Detection Prevalence : 0.6154          
##       Balanced Accuracy : 0.5213          
##                                           
##        'Positive' Class : spontaneous     
## 
# 8I offset
set.seed(1973)
smile__tree_model_8I <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + offset_mean + eye_mean,
method = "rpart", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_8I$results
##           cp  Accuracy      Kappa AccuracySD    KappaSD
## 1 0.04848485 0.5494820 0.10103869 0.04264550 0.08677768
## 2 0.05454545 0.5464516 0.09556325 0.04163563 0.08389847
## 3 0.18787879 0.5076649 0.01960290 0.05893775 0.12183508
smile__tree_model_8I$coefnames
## [1] "AU06_r_mean" "AU12_r_mean" "AU45_r_mean" "offset_mean" "eye_mean"
varImp(smile__tree_model_8I)
## rpart variable importance
## 
##             Overall
## AU45_r_mean  100.00
## offset_mean   59.63
## eye_mean      58.79
## AU06_r_mean   31.92
## AU12_r_mean    0.00
# summary(smile__tree_model_8I$finalModel)
fancyRpartPlot(smile__tree_model_8I$finalModel)

smile__tree_model_8I_pred <- predict(smile__tree_model_8I, tst_smile)
summary(smile__tree_model_8I_pred)
## spontaneous deliberate  
##          92          50
smile__tree_model_8I_confM <- confusionMatrix(
  smile__tree_model_8I_pred,
  tst_smile$smile_type
)
smile__tree_model_8I_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          46          46
##   deliberate           24          26
##                                           
##                Accuracy : 0.507           
##                  95% CI : (0.4219, 0.5919)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.53358         
##                                           
##                   Kappa : 0.0182          
##                                           
##  Mcnemar's Test P-Value : 0.01207         
##                                           
##             Sensitivity : 0.6571          
##             Specificity : 0.3611          
##          Pos Pred Value : 0.5000          
##          Neg Pred Value : 0.5200          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3239          
##    Detection Prevalence : 0.6479          
##       Balanced Accuracy : 0.5091          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_8I.1_pred <- predict(smile__tree_model_8I, tst_smile_boys)
summary(smile__tree_model_8I.1_pred)
## spontaneous deliberate  
##          49          28
smile__tree_model_8I.1_confM <- confusionMatrix(
  smile__tree_model_8I.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_8I.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          24          25
##   deliberate           13          15
##                                         
##                Accuracy : 0.5065        
##                  95% CI : (0.39, 0.6224)
##     No Information Rate : 0.5195        
##     P-Value [Acc > NIR] : 0.63425       
##                                         
##                   Kappa : 0.0234        
##                                         
##  Mcnemar's Test P-Value : 0.07435       
##                                         
##             Sensitivity : 0.6486        
##             Specificity : 0.3750        
##          Pos Pred Value : 0.4898        
##          Neg Pred Value : 0.5357        
##              Prevalence : 0.4805        
##          Detection Rate : 0.3117        
##    Detection Prevalence : 0.6364        
##       Balanced Accuracy : 0.5118        
##                                         
##        'Positive' Class : spontaneous   
## 
set.seed(1973)
smile__tree_model_8I.2_pred <- predict(smile__tree_model_8I, tst_smile_girls)
summary(smile__tree_model_8I.2_pred)
## spontaneous deliberate  
##          43          22
smile__tree_model_8I.2_confM <- confusionMatrix(
  smile__tree_model_8I.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_8I.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          22          21
##   deliberate           11          11
##                                          
##                Accuracy : 0.5077         
##                  95% CI : (0.3807, 0.634)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.5495         
##                                          
##                   Kappa : 0.0105         
##                                          
##  Mcnemar's Test P-Value : 0.1116         
##                                          
##             Sensitivity : 0.6667         
##             Specificity : 0.3438         
##          Pos Pred Value : 0.5116         
##          Neg Pred Value : 0.5000         
##              Prevalence : 0.5077         
##          Detection Rate : 0.3385         
##    Detection Prevalence : 0.6615         
##       Balanced Accuracy : 0.5052         
##                                          
##        'Positive' Class : spontaneous    
## 
# 8J
set.seed(1973)
smile__tree_model_8J <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + onset_mean + apex_mean +
  offset_mean + lip_mean,
method = "rpart", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__tree_model_8J$results
##           cp  Accuracy      Kappa AccuracySD    KappaSD
## 1 0.03636364 0.5704267 0.14211785 0.04974950 0.09859519
## 2 0.05454545 0.5493928 0.09982095 0.04575070 0.09183336
## 3 0.18787879 0.5223708 0.04901466 0.03672728 0.07788091
smile__tree_model_8J$coefnames
## [1] "AU06_r_mean" "AU12_r_mean" "AU45_r_mean" "onset_mean"  "apex_mean"  
## [6] "offset_mean" "lip_mean"
varImp(smile__tree_model_8J)
## rpart variable importance
## 
##             Overall
## AU45_r_mean  100.00
## offset_mean   69.75
## AU06_r_mean   48.99
## onset_mean    46.87
## apex_mean     39.60
## AU12_r_mean    0.00
## lip_mean       0.00
# summary(smile__tree_model_8J$finalModel)
fancyRpartPlot(smile__tree_model_8J$finalModel)

smile__tree_model_8J_pred <- predict(smile__tree_model_8J, tst_smile)
summary(smile__tree_model_8J_pred)
## spontaneous deliberate  
##          92          50
smile__tree_model_8J_confM <- confusionMatrix(
  smile__tree_model_8J_pred,
  tst_smile$smile_type
)
smile__tree_model_8J_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          46          46
##   deliberate           24          26
##                                           
##                Accuracy : 0.507           
##                  95% CI : (0.4219, 0.5919)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.53358         
##                                           
##                   Kappa : 0.0182          
##                                           
##  Mcnemar's Test P-Value : 0.01207         
##                                           
##             Sensitivity : 0.6571          
##             Specificity : 0.3611          
##          Pos Pred Value : 0.5000          
##          Neg Pred Value : 0.5200          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3239          
##    Detection Prevalence : 0.6479          
##       Balanced Accuracy : 0.5091          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__tree_model_8J.1_pred <- predict(smile__tree_model_8J, tst_smile_boys)
summary(smile__tree_model_8J.1_pred)
## spontaneous deliberate  
##          49          28
smile__tree_model_8J.1_confM <- confusionMatrix(
  smile__tree_model_8J.1_pred,
  tst_smile_boys$smile_type
)
smile__tree_model_8J.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          24          25
##   deliberate           13          15
##                                         
##                Accuracy : 0.5065        
##                  95% CI : (0.39, 0.6224)
##     No Information Rate : 0.5195        
##     P-Value [Acc > NIR] : 0.63425       
##                                         
##                   Kappa : 0.0234        
##                                         
##  Mcnemar's Test P-Value : 0.07435       
##                                         
##             Sensitivity : 0.6486        
##             Specificity : 0.3750        
##          Pos Pred Value : 0.4898        
##          Neg Pred Value : 0.5357        
##              Prevalence : 0.4805        
##          Detection Rate : 0.3117        
##    Detection Prevalence : 0.6364        
##       Balanced Accuracy : 0.5118        
##                                         
##        'Positive' Class : spontaneous   
## 
set.seed(1973)
smile__tree_model_8J.2_pred <- predict(smile__tree_model_8J, tst_smile_girls)
summary(smile__tree_model_8J.2_pred)
## spontaneous deliberate  
##          43          22
smile__tree_model_8J.2_confM <- confusionMatrix(
  smile__tree_model_8J.2_pred,
  tst_smile_girls$smile_type
)
smile__tree_model_8J.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          22          21
##   deliberate           11          11
##                                          
##                Accuracy : 0.5077         
##                  95% CI : (0.3807, 0.634)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.5495         
##                                          
##                   Kappa : 0.0105         
##                                          
##  Mcnemar's Test P-Value : 0.1116         
##                                          
##             Sensitivity : 0.6667         
##             Specificity : 0.3438         
##          Pos Pred Value : 0.5116         
##          Neg Pred Value : 0.5000         
##              Prevalence : 0.5077         
##          Detection Rate : 0.3385         
##    Detection Prevalence : 0.6615         
##       Balanced Accuracy : 0.5052         
##                                          
##        'Positive' Class : spontaneous    
## 

SVM complete model

For SVM the kernlab package is used. The method used in the caret package is svmlinear. More information about the ksvm packages can be found in the citation link or ? R help function. The trained models are divided into the same eight categories as decision trees. Two additional strong models were build for SVM. Again, multiple models per category are explored. The explanation on the categories can be found in the thesis. To train the models the train() function is used. The models are stored as variable. The parameter settings are explained in the thesis. The models use 10 fold cross-validation. The same pre-processing check is added to the complete model. On this first complete model, a ROC example has been visualized. As this is not an evaluation parameter in the thesis, it is not used any further. The cost function (C) is set to \(1\) which is the default in for this model. To visualize the trained SVM based on two features the kernlab plot is used. Some examples are displayed in the code. The predict() function is used to create the predictions based on the test set, and stored as variable. For model evaluation the confusionMatrix() function is used and printed.

# load packages
library(kernlab)

# set seed
set.seed(1973)

# complete model 0 with cost function set to 1 (default)
smile__svm_model_0 <- train(smile_type ~ .,
  method = "svmLinear", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

# check different parameters of the model results
smile__svm_model_0
## Support Vector Machines with Linear Kernel 
## 
## 333 samples
##  32 predictor
##   2 classes: 'spontaneous', 'deliberate ' 
## 
## No pre-processing
## Resampling: Cross-Validated (10 fold) 
## Summary of sample sizes: 300, 300, 300, 299, 299, 300, ... 
## Resampling results:
## 
##   Accuracy   Kappa    
##   0.7050914  0.4098127
## 
## Tuning parameter 'C' was held constant at a value of 1
smile__svm_model_0$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.7050914 0.4098127  0.1064684 0.2126184
smile__svm_model_0$resample
##     Accuracy      Kappa Resample
## 1  0.8181818 0.63602941   Fold01
## 2  0.7878788 0.57458564   Fold02
## 3  0.6666667 0.33394495   Fold03
## 4  0.7941176 0.58823529   Fold04
## 5  0.5294118 0.05882353   Fold05
## 6  0.7272727 0.45101664   Fold06
## 7  0.6060606 0.21284404   Fold07
## 8  0.7941176 0.58823529   Fold08
## 9  0.5625000 0.12500000   Fold09
## 10 0.7647059 0.52941176   Fold10
smile__svm_model_0$bestTune
##   C
## 1 1
# summary(smile__svm_model_0$finalModel) - not printed

# prediction on the test set and the model
smile__svm_model_0_pred <- predict(smile__svm_model_0, newdata = tst_smile)

# print prediction
summary(smile__svm_model_0_pred)
## spontaneous deliberate  
##          67          75
# Evaluation of the accuracy based on the confusion matrix
smile__svm_model_0_confM <- confusionMatrix(
  smile__svm_model_0_pred,
  tst_smile$smile_type
)

# print the confusion matrix
smile__svm_model_0_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          50          17
##   deliberate           20          55
##                                           
##                Accuracy : 0.7394          
##                  95% CI : (0.6592, 0.8094)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 1.288e-08       
##                                           
##                   Kappa : 0.4785          
##                                           
##  Mcnemar's Test P-Value : 0.7423          
##                                           
##             Sensitivity : 0.7143          
##             Specificity : 0.7639          
##          Pos Pred Value : 0.7463          
##          Neg Pred Value : 0.7333          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3521          
##    Detection Prevalence : 0.4718          
##       Balanced Accuracy : 0.7391          
##                                           
##        'Positive' Class : spontaneous     
## 
# set seed
set.seed(1973)

# complete model 0 + pre-processing - outcome does not improve!
smile__svm_model_0.0.1 <- train(smile_type ~ .,
  method = "svmLinear", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10),
  preProcess = c("center", "scale")
)
smile__svm_model_0.0.1
## Support Vector Machines with Linear Kernel 
## 
## 333 samples
##  32 predictor
##   2 classes: 'spontaneous', 'deliberate ' 
## 
## Pre-processing: centered (32), scaled (32) 
## Resampling: Cross-Validated (10 fold) 
## Summary of sample sizes: 300, 300, 300, 299, 299, 300, ... 
## Resampling results:
## 
##   Accuracy   Kappa    
##   0.7050914  0.4098127
## 
## Tuning parameter 'C' was held constant at a value of 1
smile__svm_model_0.0.1$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.7050914 0.4098127  0.1064684 0.2126184
# predicting boys, girls
set.seed(1973)
smile__svm_model_0.1_pred <- predict(smile__svm_model_0, tst_smile_boys)
summary(smile__svm_model_0.1_pred)
## spontaneous deliberate  
##          33          44
smile__svm_model_0.1_confM <- confusionMatrix(
  smile__svm_model_0.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_0.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          26           7
##   deliberate           11          33
##                                           
##                Accuracy : 0.7662          
##                  95% CI : (0.6559, 0.8552)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 7.359e-06       
##                                           
##                   Kappa : 0.5299          
##                                           
##  Mcnemar's Test P-Value : 0.4795          
##                                           
##             Sensitivity : 0.7027          
##             Specificity : 0.8250          
##          Pos Pred Value : 0.7879          
##          Neg Pred Value : 0.7500          
##              Prevalence : 0.4805          
##          Detection Rate : 0.3377          
##    Detection Prevalence : 0.4286          
##       Balanced Accuracy : 0.7639          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_0.2_pred <- predict(smile__svm_model_0, tst_smile_girls)
summary(smile__svm_model_0.2_pred)
## spontaneous deliberate  
##          34          31
smile__svm_model_0.2_confM <- confusionMatrix(
  smile__svm_model_0.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_0.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          24          10
##   deliberate            9          22
##                                          
##                Accuracy : 0.7077         
##                  95% CI : (0.5817, 0.814)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.0008348      
##                                          
##                   Kappa : 0.415          
##                                          
##  Mcnemar's Test P-Value : 1.0000000      
##                                          
##             Sensitivity : 0.7273         
##             Specificity : 0.6875         
##          Pos Pred Value : 0.7059         
##          Neg Pred Value : 0.7097         
##              Prevalence : 0.5077         
##          Detection Rate : 0.3692         
##    Detection Prevalence : 0.5231         
##       Balanced Accuracy : 0.7074         
##                                          
##        'Positive' Class : spontaneous    
## 
# example ROC

# load packages
library(pROC)
# citation("pROC")

# ROC model 0
roc_0 <- roc(
  as.numeric(tst_smile$smile_type),
  as.numeric(as.factor(smile__svm_model_0_pred))
)
roc_0
## 
## Call:
## roc.default(response = as.numeric(tst_smile$smile_type), predictor = as.numeric(as.factor(smile__svm_model_0_pred)))
## 
## Data: as.numeric(as.factor(smile__svm_model_0_pred)) in 70 controls (as.numeric(tst_smile$smile_type) 1) < 72 cases (as.numeric(tst_smile$smile_type) 2).
## Area under the curve: 0.7391
# Visualize the ROC model
par(mfrow = c(1, 1))
par(mai = c(.9, .8, .2, .2))
plot.roc(roc_0,
  print.auc = TRUE, col = "black", lwd = 1,
  main = "ROC curve", xlab = "Specificity: true negative rate",
  ylab = "Sensitivity: true positive rate",
  xlim = c(1, 0), ylim = c(0, 1), print.thres = "best"
)
abline(v = 1, lty = 2)
abline(h = 1, lty = 2)
text(.90, .97, labels = "Ideal Model")
points(1, 1, pch = "O", cex = 1.5)

# citation("kernlab")
# model 1 onset-apex-offset
set.seed(1973)
smile__svm_model_1 <- train(smile_type ~ onset_mean + offset_mean + apex_mean,
  method = "svmLinear", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)
smile__svm_model_1$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.6448362 0.2904029  0.1026657 0.2039863
smile__svm_model_1_pred <- predict(smile__svm_model_1, newdata = tst_smile)
summary(smile__svm_model_1_pred)
## spontaneous deliberate  
##          76          66
smile__svm_model_1_confM <- confusionMatrix(
  smile__svm_model_1_pred,
  tst_smile$smile_type
)
smile__svm_model_1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          47          29
##   deliberate           23          43
##                                          
##                Accuracy : 0.6338         
##                  95% CI : (0.5489, 0.713)
##     No Information Rate : 0.507          
##     P-Value [Acc > NIR] : 0.001568       
##                                          
##                   Kappa : 0.2683         
##                                          
##  Mcnemar's Test P-Value : 0.488074       
##                                          
##             Sensitivity : 0.6714         
##             Specificity : 0.5972         
##          Pos Pred Value : 0.6184         
##          Neg Pred Value : 0.6515         
##              Prevalence : 0.4930         
##          Detection Rate : 0.3310         
##    Detection Prevalence : 0.5352         
##       Balanced Accuracy : 0.6343         
##                                          
##        'Positive' Class : spontaneous    
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_1.1_pred <- predict(smile__svm_model_1, tst_smile_boys)
summary(smile__svm_model_1.1_pred)
## spontaneous deliberate  
##          38          39
smile__svm_model_1.1_confM <- confusionMatrix(
  smile__svm_model_1.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_1.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          23          15
##   deliberate           14          25
##                                           
##                Accuracy : 0.6234          
##                  95% CI : (0.5056, 0.7313)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.04297         
##                                           
##                   Kappa : 0.2464          
##                                           
##  Mcnemar's Test P-Value : 1.00000         
##                                           
##             Sensitivity : 0.6216          
##             Specificity : 0.6250          
##          Pos Pred Value : 0.6053          
##          Neg Pred Value : 0.6410          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2987          
##    Detection Prevalence : 0.4935          
##       Balanced Accuracy : 0.6233          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_1.2_pred <- predict(smile__svm_model_1, tst_smile_girls)
summary(smile__svm_model_1.2_pred)
## spontaneous deliberate  
##          38          27
smile__svm_model_1.2_confM <- confusionMatrix(
  smile__svm_model_1.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_1.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          24          14
##   deliberate            9          18
##                                           
##                Accuracy : 0.6462          
##                  95% CI : (0.5177, 0.7608)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.01698         
##                                           
##                   Kappa : 0.2905          
##                                           
##  Mcnemar's Test P-Value : 0.40425         
##                                           
##             Sensitivity : 0.7273          
##             Specificity : 0.5625          
##          Pos Pred Value : 0.6316          
##          Neg Pred Value : 0.6667          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3692          
##    Detection Prevalence : 0.5846          
##       Balanced Accuracy : 0.6449          
##                                           
##        'Positive' Class : spontaneous     
## 
# Roc model 1

roc_1 <- roc(
  as.numeric(tst_smile$smile_type),
  as.numeric(as.factor(smile__svm_model_1_pred))
)
roc_1
## 
## Call:
## roc.default(response = as.numeric(tst_smile$smile_type), predictor = as.numeric(as.factor(smile__svm_model_1_pred)))
## 
## Data: as.numeric(as.factor(smile__svm_model_1_pred)) in 70 controls (as.numeric(tst_smile$smile_type) 1) < 72 cases (as.numeric(tst_smile$smile_type) 2).
## Area under the curve: 0.6343
par(mfrow = c(1, 1))
par(mai = c(.9, .8, .2, .2))
plot.roc(roc_1,
  print.auc = TRUE, col = "black", lwd = 1,
  main = "ROC curve", xlab = "Specificity: true negative rate",
  ylab = "Sensitivity: true positive rate",
  xlim = c(1, 0), ylim = c(0, 1), print.thres = "best"
)
abline(v = 1, lty = 2)
abline(h = 1, lty = 2)
text(.90, .97, labels = "Ideal Model")
points(1, 1, pch = "O", cex = 1.5)

# model 1A onset
set.seed(1973)
smile__svm_model_1A <- train(smile_type ~ onset_mean,
  method = "svmLinear", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)
smile__svm_model_1A$results
##   C  Accuracy         Kappa AccuracySD   KappaSD
## 1 1 0.4977607 -0.0005964829 0.07121788 0.1409985
smile__svm_model_1A_pred <- predict(smile__svm_model_1A, newdata = tst_smile)
summary(smile__svm_model_1A_pred)
## spontaneous deliberate  
##          72          70
smile__svm_model_1A_confM <- confusionMatrix(
  smile__svm_model_1A_pred,
  tst_smile$smile_type
)
smile__svm_model_1A_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          42          30
##   deliberate           28          42
##                                          
##                Accuracy : 0.5915         
##                  95% CI : (0.506, 0.6732)
##     No Information Rate : 0.507          
##     P-Value [Acc > NIR] : 0.02653        
##                                          
##                   Kappa : 0.1833         
##                                          
##  Mcnemar's Test P-Value : 0.89553        
##                                          
##             Sensitivity : 0.6000         
##             Specificity : 0.5833         
##          Pos Pred Value : 0.5833         
##          Neg Pred Value : 0.6000         
##              Prevalence : 0.4930         
##          Detection Rate : 0.2958         
##    Detection Prevalence : 0.5070         
##       Balanced Accuracy : 0.5917         
##                                          
##        'Positive' Class : spontaneous    
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_1A.1_pred <- predict(smile__svm_model_1A, tst_smile_boys)
summary(smile__svm_model_1A.1_pred)
## spontaneous deliberate  
##          37          40
smile__svm_model_1A.1_confM <- confusionMatrix(
  smile__svm_model_1A.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_1A.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          21          16
##   deliberate           16          24
##                                           
##                Accuracy : 0.5844          
##                  95% CI : (0.4664, 0.6957)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.1523          
##                                           
##                   Kappa : 0.1676          
##                                           
##  Mcnemar's Test P-Value : 1.0000          
##                                           
##             Sensitivity : 0.5676          
##             Specificity : 0.6000          
##          Pos Pred Value : 0.5676          
##          Neg Pred Value : 0.6000          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2727          
##    Detection Prevalence : 0.4805          
##       Balanced Accuracy : 0.5838          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_1A.2_pred <- predict(smile__svm_model_1A, tst_smile_girls)
summary(smile__svm_model_1A.2_pred)
## spontaneous deliberate  
##          35          30
smile__svm_model_1A.2_confM <- confusionMatrix(
  smile__svm_model_1A.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_1A.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          21          14
##   deliberate           12          18
##                                          
##                Accuracy : 0.6            
##                  95% CI : (0.471, 0.7196)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.08588        
##                                          
##                   Kappa : 0.1991         
##                                          
##  Mcnemar's Test P-Value : 0.84452        
##                                          
##             Sensitivity : 0.6364         
##             Specificity : 0.5625         
##          Pos Pred Value : 0.6000         
##          Neg Pred Value : 0.6000         
##              Prevalence : 0.5077         
##          Detection Rate : 0.3231         
##    Detection Prevalence : 0.5385         
##       Balanced Accuracy : 0.5994         
##                                          
##        'Positive' Class : spontaneous    
## 
# model 1B apex
set.seed(1973)
smile__svm_model_1B <- train(smile_type ~ apex_mean,
  method = "svmLinear", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)
smile__svm_model_1B$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.5408422 0.0803652 0.07503868 0.1492659
smile__svm_model_1B_pred <- predict(smile__svm_model_1B, newdata = tst_smile)
summary(smile__svm_model_1B_pred)
## spontaneous deliberate  
##          57          85
smile__svm_model_1B_confM <- confusionMatrix(
  smile__svm_model_1B_pred,
  tst_smile$smile_type
)
smile__svm_model_1B_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          26          31
##   deliberate           44          41
##                                           
##                Accuracy : 0.4718          
##                  95% CI : (0.3876, 0.5573)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.8220          
##                                           
##                   Kappa : -0.0593         
##                                           
##  Mcnemar's Test P-Value : 0.1659          
##                                           
##             Sensitivity : 0.3714          
##             Specificity : 0.5694          
##          Pos Pred Value : 0.4561          
##          Neg Pred Value : 0.4824          
##              Prevalence : 0.4930          
##          Detection Rate : 0.1831          
##    Detection Prevalence : 0.4014          
##       Balanced Accuracy : 0.4704          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_1B.1_pred <- predict(smile__svm_model_1B, tst_smile_boys)
summary(smile__svm_model_1B.1_pred)
## spontaneous deliberate  
##          31          46
smile__svm_model_1B.1_confM <- confusionMatrix(
  smile__svm_model_1B.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_1B.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          15          16
##   deliberate           22          24
##                                         
##                Accuracy : 0.5065        
##                  95% CI : (0.39, 0.6224)
##     No Information Rate : 0.5195        
##     P-Value [Acc > NIR] : 0.6342        
##                                         
##                   Kappa : 0.0054        
##                                         
##  Mcnemar's Test P-Value : 0.4173        
##                                         
##             Sensitivity : 0.4054        
##             Specificity : 0.6000        
##          Pos Pred Value : 0.4839        
##          Neg Pred Value : 0.5217        
##              Prevalence : 0.4805        
##          Detection Rate : 0.1948        
##    Detection Prevalence : 0.4026        
##       Balanced Accuracy : 0.5027        
##                                         
##        'Positive' Class : spontaneous   
## 
set.seed(1973)
smile__svm_model_1B.2_pred <- predict(smile__svm_model_1B, tst_smile_girls)
summary(smile__svm_model_1B.2_pred)
## spontaneous deliberate  
##          26          39
smile__svm_model_1B.2_confM <- confusionMatrix(
  smile__svm_model_1B.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_1B.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          11          15
##   deliberate           22          17
##                                           
##                Accuracy : 0.4308          
##                  95% CI : (0.3085, 0.5596)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.9139          
##                                           
##                   Kappa : -0.135          
##                                           
##  Mcnemar's Test P-Value : 0.3239          
##                                           
##             Sensitivity : 0.3333          
##             Specificity : 0.5312          
##          Pos Pred Value : 0.4231          
##          Neg Pred Value : 0.4359          
##              Prevalence : 0.5077          
##          Detection Rate : 0.1692          
##    Detection Prevalence : 0.4000          
##       Balanced Accuracy : 0.4323          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 1C offset
set.seed(1973)
smile__svm_model_1C <- train(smile_type ~ offset_mean,
  method = "svmLinear", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)
smile__svm_model_1C$results
##   C  Accuracy      Kappa AccuracySD   KappaSD
## 1 1 0.5464294 0.09219777 0.05082367 0.1022998
smile__svm_model_1C_pred <- predict(smile__svm_model_1C, newdata = tst_smile)
summary(smile__svm_model_1C_pred)
## spontaneous deliberate  
##          76          66
smile__svm_model_1C_confM <- confusionMatrix(
  smile__svm_model_1C_pred,
  tst_smile$smile_type
)
smile__svm_model_1C_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          45          31
##   deliberate           25          41
##                                           
##                Accuracy : 0.6056          
##                  95% CI : (0.5202, 0.6865)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.01151         
##                                           
##                   Kappa : 0.212           
##                                           
##  Mcnemar's Test P-Value : 0.50404         
##                                           
##             Sensitivity : 0.6429          
##             Specificity : 0.5694          
##          Pos Pred Value : 0.5921          
##          Neg Pred Value : 0.6212          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3169          
##    Detection Prevalence : 0.5352          
##       Balanced Accuracy : 0.6062          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_1C.1_pred <- predict(smile__svm_model_1C, tst_smile_boys)
summary(smile__svm_model_1C.1_pred)
## spontaneous deliberate  
##          40          37
smile__svm_model_1C.1_confM <- confusionMatrix(
  smile__svm_model_1C.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_1C.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          22          18
##   deliberate           15          22
##                                           
##                Accuracy : 0.5714          
##                  95% CI : (0.4535, 0.6837)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.2126          
##                                           
##                   Kappa : 0.1442          
##                                           
##  Mcnemar's Test P-Value : 0.7277          
##                                           
##             Sensitivity : 0.5946          
##             Specificity : 0.5500          
##          Pos Pred Value : 0.5500          
##          Neg Pred Value : 0.5946          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2857          
##    Detection Prevalence : 0.5195          
##       Balanced Accuracy : 0.5723          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_1C.2_pred <- predict(smile__svm_model_1C, tst_smile_girls)
summary(smile__svm_model_1C.2_pred)
## spontaneous deliberate  
##          36          29
smile__svm_model_1C.2_confM <- confusionMatrix(
  smile__svm_model_1C.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_1C.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          23          13
##   deliberate           10          19
##                                           
##                Accuracy : 0.6462          
##                  95% CI : (0.5177, 0.7608)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.01698         
##                                           
##                   Kappa : 0.2911          
##                                           
##  Mcnemar's Test P-Value : 0.67666         
##                                           
##             Sensitivity : 0.6970          
##             Specificity : 0.5938          
##          Pos Pred Value : 0.6389          
##          Neg Pred Value : 0.6552          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3538          
##    Detection Prevalence : 0.5538          
##       Balanced Accuracy : 0.6454          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 2 complete excluding subject info
set.seed(1973)
smile__svm_model_2 <- train(smile_type ~ . - subject - age,
  method = "svmLinear", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10),
)

smile__svm_model_2$results
##   C Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.728799 0.4571015  0.1104272 0.2212161
smile__svm_model_2_pred <- predict(smile__svm_model_2, tst_smile)
summary(smile__svm_model_2_pred)
## spontaneous deliberate  
##          61          81
smile__tree_svm_2_confM <- confusionMatrix(
  smile__svm_model_2_pred,
  tst_smile$smile_type
)
smile__tree_svm_2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          44          17
##   deliberate           26          55
##                                           
##                Accuracy : 0.6972          
##                  95% CI : (0.6145, 0.7714)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 3.274e-06       
##                                           
##                   Kappa : 0.3932          
##                                           
##  Mcnemar's Test P-Value : 0.2225          
##                                           
##             Sensitivity : 0.6286          
##             Specificity : 0.7639          
##          Pos Pred Value : 0.7213          
##          Neg Pred Value : 0.6790          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3099          
##    Detection Prevalence : 0.4296          
##       Balanced Accuracy : 0.6962          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_2.1_pred <- predict(smile__svm_model_2, tst_smile_boys)
summary(smile__svm_model_2.1_pred)
## spontaneous deliberate  
##          28          49
smile__svm_model_2.1_confM <- confusionMatrix(
  smile__svm_model_2.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_2.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          22           6
##   deliberate           15          34
##                                           
##                Accuracy : 0.7273          
##                  95% CI : (0.6138, 0.8226)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.0001583       
##                                           
##                   Kappa : 0.4487          
##                                           
##  Mcnemar's Test P-Value : 0.0808556       
##                                           
##             Sensitivity : 0.5946          
##             Specificity : 0.8500          
##          Pos Pred Value : 0.7857          
##          Neg Pred Value : 0.6939          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2857          
##    Detection Prevalence : 0.3636          
##       Balanced Accuracy : 0.7223          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_2.2_pred <- predict(smile__svm_model_2, tst_smile_girls)
summary(smile__svm_model_2.2_pred)
## spontaneous deliberate  
##          33          32
smile__svm_model_2.2_confM <- confusionMatrix(
  smile__svm_model_2.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_2.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          22          11
##   deliberate           11          21
##                                           
##                Accuracy : 0.6615          
##                  95% CI : (0.5335, 0.7743)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.008794        
##                                           
##                   Kappa : 0.3229          
##                                           
##  Mcnemar's Test P-Value : 1.000000        
##                                           
##             Sensitivity : 0.6667          
##             Specificity : 0.6562          
##          Pos Pred Value : 0.6667          
##          Neg Pred Value : 0.6562          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3385          
##    Detection Prevalence : 0.5077          
##       Balanced Accuracy : 0.6615          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 3 complete lip and eye features
set.seed(1973)
smile__svm_model_3 <- train(smile_type ~ lip_mean + eye_mean,
  method = "svmLinear", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_3$results
##   C  Accuracy      Kappa AccuracySD   KappaSD
## 1 1 0.5143661 0.02580907 0.08044698 0.1609386
summary(smile__svm_model_3$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
kernlab::plot(smile__svm_model_3$finalModel)

smile__svm_model_3_pred <- predict(smile__svm_model_3, tst_smile)
summary(smile__svm_model_3_pred)
## spontaneous deliberate  
##          55          87
smile__svm_model_3_confM <- confusionMatrix(
  smile__svm_model_3_pred,
  tst_smile$smile_type
)
smile__svm_model_3_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          31          24
##   deliberate           39          48
##                                           
##                Accuracy : 0.5563          
##                  95% CI : (0.4707, 0.6396)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.13758         
##                                           
##                   Kappa : 0.1099          
##                                           
##  Mcnemar's Test P-Value : 0.07776         
##                                           
##             Sensitivity : 0.4429          
##             Specificity : 0.6667          
##          Pos Pred Value : 0.5636          
##          Neg Pred Value : 0.5517          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2183          
##    Detection Prevalence : 0.3873          
##       Balanced Accuracy : 0.5548          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_3.1_pred <- predict(smile__svm_model_3, tst_smile_boys)
summary(smile__svm_model_3.1_pred)
## spontaneous deliberate  
##          28          49
smile__svm_model_3.1_confM <- confusionMatrix(
  smile__svm_model_3.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_3.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          17          11
##   deliberate           20          29
##                                           
##                Accuracy : 0.5974          
##                  95% CI : (0.4794, 0.7077)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.1045          
##                                           
##                   Kappa : 0.1862          
##                                           
##  Mcnemar's Test P-Value : 0.1508          
##                                           
##             Sensitivity : 0.4595          
##             Specificity : 0.7250          
##          Pos Pred Value : 0.6071          
##          Neg Pred Value : 0.5918          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2208          
##    Detection Prevalence : 0.3636          
##       Balanced Accuracy : 0.5922          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_3.2_pred <- predict(smile__svm_model_3, tst_smile_girls)
summary(smile__svm_model_3.2_pred)
## spontaneous deliberate  
##          27          38
smile__svm_model_3.2_confM <- confusionMatrix(
  smile__svm_model_3.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_3.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          14          13
##   deliberate           19          19
##                                          
##                Accuracy : 0.5077         
##                  95% CI : (0.3807, 0.634)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.5495         
##                                          
##                   Kappa : 0.0179         
##                                          
##  Mcnemar's Test P-Value : 0.3768         
##                                          
##             Sensitivity : 0.4242         
##             Specificity : 0.5938         
##          Pos Pred Value : 0.5185         
##          Neg Pred Value : 0.5000         
##              Prevalence : 0.5077         
##          Detection Rate : 0.2154         
##    Detection Prevalence : 0.4154         
##       Balanced Accuracy : 0.5090         
##                                          
##        'Positive' Class : spontaneous    
## 
# model 3A complete lip and eye features
set.seed(1973)
smile__svm_model_3A <- train(smile_type ~ lip_mean,
  method = "svmLinear", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_3A$results
##   C  Accuracy      Kappa AccuracySD   KappaSD
## 1 1 0.5262255 0.05020194 0.08590419 0.1693449
summary(smile__svm_model_3A$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_3A_pred <- predict(smile__svm_model_3A, tst_smile)
summary(smile__svm_model_3A_pred)
## spontaneous deliberate  
##          46          96
smile__svm_model_3A_confM <- confusionMatrix(
  smile__svm_model_3A_pred,
  tst_smile$smile_type
)
smile__svm_model_3A_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          23          23
##   deliberate           47          49
##                                           
##                Accuracy : 0.507           
##                  95% CI : (0.4219, 0.5919)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.533579        
##                                           
##                   Kappa : 0.0092          
##                                           
##  Mcnemar's Test P-Value : 0.005977        
##                                           
##             Sensitivity : 0.3286          
##             Specificity : 0.6806          
##          Pos Pred Value : 0.5000          
##          Neg Pred Value : 0.5104          
##              Prevalence : 0.4930          
##          Detection Rate : 0.1620          
##    Detection Prevalence : 0.3239          
##       Balanced Accuracy : 0.5046          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_3A.1_pred <- predict(smile__svm_model_3A, tst_smile_boys)
summary(smile__svm_model_3A.1_pred)
## spontaneous deliberate  
##          24          53
smile__svm_model_3A.1_confM <- confusionMatrix(
  smile__svm_model_3A.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_3A.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          13          11
##   deliberate           24          29
##                                           
##                Accuracy : 0.5455          
##                  95% CI : (0.4279, 0.6594)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.36674         
##                                           
##                   Kappa : 0.0774          
##                                           
##  Mcnemar's Test P-Value : 0.04252         
##                                           
##             Sensitivity : 0.3514          
##             Specificity : 0.7250          
##          Pos Pred Value : 0.5417          
##          Neg Pred Value : 0.5472          
##              Prevalence : 0.4805          
##          Detection Rate : 0.1688          
##    Detection Prevalence : 0.3117          
##       Balanced Accuracy : 0.5382          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_3A.2_pred <- predict(smile__svm_model_3A, tst_smile_girls)
summary(smile__svm_model_3A.2_pred)
## spontaneous deliberate  
##          22          43
smile__svm_model_3A.2_confM <- confusionMatrix(
  smile__svm_model_3A.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_3A.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          10          12
##   deliberate           23          20
##                                          
##                Accuracy : 0.4615         
##                  95% CI : (0.337, 0.5897)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.80736        
##                                          
##                   Kappa : -0.0716        
##                                          
##  Mcnemar's Test P-Value : 0.09097        
##                                          
##             Sensitivity : 0.3030         
##             Specificity : 0.6250         
##          Pos Pred Value : 0.4545         
##          Neg Pred Value : 0.4651         
##              Prevalence : 0.5077         
##          Detection Rate : 0.1538         
##    Detection Prevalence : 0.3385         
##       Balanced Accuracy : 0.4640         
##                                          
##        'Positive' Class : spontaneous    
## 
# model 3B eye
set.seed(1973)
smile__svm_model_3B <- train(smile_type ~ eye_mean,
  method = "svmLinear", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_3B$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.5529523 0.1030544 0.09511338 0.1911904
summary(smile__svm_model_3B$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_3B_pred <- predict(smile__svm_model_3B, tst_smile)
summary(smile__svm_model_3B_pred)
## spontaneous deliberate  
##          50          92
smile__svm_model_3B_confM <- confusionMatrix(
  smile__svm_model_3B_pred,
  tst_smile$smile_type
)
smile__svm_model_3B_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          30          20
##   deliberate           40          52
##                                           
##                Accuracy : 0.5775          
##                  95% CI : (0.4918, 0.6598)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.05517         
##                                           
##                   Kappa : 0.1514          
##                                           
##  Mcnemar's Test P-Value : 0.01417         
##                                           
##             Sensitivity : 0.4286          
##             Specificity : 0.7222          
##          Pos Pred Value : 0.6000          
##          Neg Pred Value : 0.5652          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2113          
##    Detection Prevalence : 0.3521          
##       Balanced Accuracy : 0.5754          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_3B.1_pred <- predict(smile__svm_model_3B, tst_smile_boys)
summary(smile__svm_model_3B.1_pred)
## spontaneous deliberate  
##          26          51
smile__svm_model_3B.1_confM <- confusionMatrix(
  smile__svm_model_3B.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_3B.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          16          10
##   deliberate           21          30
##                                           
##                Accuracy : 0.5974          
##                  95% CI : (0.4794, 0.7077)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.10453         
##                                           
##                   Kappa : 0.1845          
##                                           
##  Mcnemar's Test P-Value : 0.07249         
##                                           
##             Sensitivity : 0.4324          
##             Specificity : 0.7500          
##          Pos Pred Value : 0.6154          
##          Neg Pred Value : 0.5882          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2078          
##    Detection Prevalence : 0.3377          
##       Balanced Accuracy : 0.5912          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_3B.2_pred <- predict(smile__svm_model_3B, tst_smile_girls)
summary(smile__svm_model_3B.2_pred)
## spontaneous deliberate  
##          24          41
smile__svm_model_3B.2_confM <- confusionMatrix(
  smile__svm_model_3B.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_3B.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          14          10
##   deliberate           19          22
##                                           
##                Accuracy : 0.5538          
##                  95% CI : (0.4253, 0.6773)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.2678          
##                                           
##                   Kappa : 0.1113          
##                                           
##  Mcnemar's Test P-Value : 0.1374          
##                                           
##             Sensitivity : 0.4242          
##             Specificity : 0.6875          
##          Pos Pred Value : 0.5833          
##          Neg Pred Value : 0.5366          
##              Prevalence : 0.5077          
##          Detection Rate : 0.2154          
##    Detection Prevalence : 0.3692          
##       Balanced Accuracy : 0.5559          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 3C lip
set.seed(1973)
smile__svm_model_3C <- train(smile_type ~ eye_mean + lip_mean + amplitude_mean,
  method = "svmLinear", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_3C$results
##   C  Accuracy      Kappa AccuracySD   KappaSD
## 1 1 0.5143661 0.02580907 0.08044698 0.1609386
summary(smile__svm_model_3C$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_3C_pred <- predict(smile__svm_model_3C, tst_smile)
summary(smile__svm_model_3C_pred)
## spontaneous deliberate  
##          55          87
smile__svm_model_3C_confM <- confusionMatrix(
  smile__svm_model_3C_pred,
  tst_smile$smile_type
)
smile__svm_model_3C_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          31          24
##   deliberate           39          48
##                                           
##                Accuracy : 0.5563          
##                  95% CI : (0.4707, 0.6396)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.13758         
##                                           
##                   Kappa : 0.1099          
##                                           
##  Mcnemar's Test P-Value : 0.07776         
##                                           
##             Sensitivity : 0.4429          
##             Specificity : 0.6667          
##          Pos Pred Value : 0.5636          
##          Neg Pred Value : 0.5517          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2183          
##    Detection Prevalence : 0.3873          
##       Balanced Accuracy : 0.5548          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_3C.1_pred <- predict(smile__svm_model_3C, tst_smile_boys)
summary(smile__svm_model_3C.1_pred)
## spontaneous deliberate  
##          28          49
smile__svm_model_3C.1_confM <- confusionMatrix(
  smile__svm_model_3C.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_3C.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          17          11
##   deliberate           20          29
##                                           
##                Accuracy : 0.5974          
##                  95% CI : (0.4794, 0.7077)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.1045          
##                                           
##                   Kappa : 0.1862          
##                                           
##  Mcnemar's Test P-Value : 0.1508          
##                                           
##             Sensitivity : 0.4595          
##             Specificity : 0.7250          
##          Pos Pred Value : 0.6071          
##          Neg Pred Value : 0.5918          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2208          
##    Detection Prevalence : 0.3636          
##       Balanced Accuracy : 0.5922          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_3C.2_pred <- predict(smile__svm_model_3C, tst_smile_girls)
summary(smile__svm_model_3C.2_pred)
## spontaneous deliberate  
##          27          38
smile__svm_model_3C.2_confM <- confusionMatrix(
  smile__svm_model_3C.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_3C.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          14          13
##   deliberate           19          19
##                                          
##                Accuracy : 0.5077         
##                  95% CI : (0.3807, 0.634)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.5495         
##                                          
##                   Kappa : 0.0179         
##                                          
##  Mcnemar's Test P-Value : 0.3768         
##                                          
##             Sensitivity : 0.4242         
##             Specificity : 0.5938         
##          Pos Pred Value : 0.5185         
##          Neg Pred Value : 0.5000         
##              Prevalence : 0.5077         
##          Detection Rate : 0.2154         
##    Detection Prevalence : 0.4154         
##       Balanced Accuracy : 0.5090         
##                                          
##        'Positive' Class : spontaneous    
## 
# model 4 AU features
set.seed(1973)
smile__svm_model_4 <- train(smile_type ~ AU01_r_mean + AU02_r_mean +
  AU04_r_mean + AU05_r_mean + AU06_r_mean +
  AU07_r_mean + AU09_r_mean + AU10_r_mean +
  AU12_r_mean + AU14_r_mean + AU15_r_mean +
  AU17_r_mean + AU20_r_mean + AU23_r_mean +
  AU25_r_mean + AU26_r_mean + AU45_r_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_4$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.6932765 0.3879683  0.1209849 0.2395002
summary(smile__svm_model_4$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_4_pred <- predict(smile__svm_model_4, tst_smile)
summary(smile__svm_model_4_pred)
## spontaneous deliberate  
##          60          82
smile__svm_model_4_confM <- confusionMatrix(
  smile__svm_model_4_pred,
  tst_smile$smile_type
)
smile__svm_model_4_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          35          25
##   deliberate           35          47
##                                           
##                Accuracy : 0.5775          
##                  95% CI : (0.4918, 0.6598)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.05517         
##                                           
##                   Kappa : 0.1531          
##                                           
##  Mcnemar's Test P-Value : 0.24528         
##                                           
##             Sensitivity : 0.5000          
##             Specificity : 0.6528          
##          Pos Pred Value : 0.5833          
##          Neg Pred Value : 0.5732          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2465          
##    Detection Prevalence : 0.4225          
##       Balanced Accuracy : 0.5764          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_4.1_pred <- predict(smile__svm_model_4, tst_smile_boys)
summary(smile__svm_model_4.1_pred)
## spontaneous deliberate  
##          34          43
smile__svm_model_4.1_confM <- confusionMatrix(
  smile__svm_model_4.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_4.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          21          13
##   deliberate           16          27
##                                           
##                Accuracy : 0.6234          
##                  95% CI : (0.5056, 0.7313)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.04297         
##                                           
##                   Kappa : 0.2433          
##                                           
##  Mcnemar's Test P-Value : 0.71035         
##                                           
##             Sensitivity : 0.5676          
##             Specificity : 0.6750          
##          Pos Pred Value : 0.6176          
##          Neg Pred Value : 0.6279          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2727          
##    Detection Prevalence : 0.4416          
##       Balanced Accuracy : 0.6213          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_4.2_pred <- predict(smile__svm_model_4, tst_smile_girls)
summary(smile__svm_model_4.2_pred)
## spontaneous deliberate  
##          26          39
smile__svm_model_4.2_confM <- confusionMatrix(
  smile__svm_model_4.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_4.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          14          12
##   deliberate           19          20
##                                           
##                Accuracy : 0.5231          
##                  95% CI : (0.3954, 0.6485)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.4510          
##                                           
##                   Kappa : 0.0491          
##                                           
##  Mcnemar's Test P-Value : 0.2812          
##                                           
##             Sensitivity : 0.4242          
##             Specificity : 0.6250          
##          Pos Pred Value : 0.5385          
##          Neg Pred Value : 0.5128          
##              Prevalence : 0.5077          
##          Detection Rate : 0.2154          
##    Detection Prevalence : 0.4000          
##       Balanced Accuracy : 0.5246          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 4A AU happiness model
set.seed(1973)
smile__svm_model_4A <- train(smile_type ~ AU06_r_mean + AU12_r_mean,
  method = "svmLinear",
  data = trn_smile,
  trControl = trainControl(
    method = "cv",
    number = 10
  )
)

smile__svm_model_4A$results
##   C  Accuracy      Kappa AccuracySD   KappaSD
## 1 1 0.5249387 0.04894662 0.07451885 0.1516131
summary(smile__svm_model_4A$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
kernlab::plot(smile__svm_model_4A$finalModel, xlab = "AU12", ylab = "AU06")

smile__svm_model_4A_pred <- predict(smile__svm_model_4A, tst_smile)
summary(smile__svm_model_4A_pred)
## spontaneous deliberate  
##          41         101
smile__svm_model_4A_confM <- confusionMatrix(
  smile__svm_model_4A_pred,
  tst_smile$smile_type
)
smile__svm_model_4A_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          23          18
##   deliberate           47          54
##                                           
##                Accuracy : 0.5423          
##                  95% CI : (0.4567, 0.6261)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.2251326       
##                                           
##                   Kappa : 0.079           
##                                           
##  Mcnemar's Test P-Value : 0.0005147       
##                                           
##             Sensitivity : 0.3286          
##             Specificity : 0.7500          
##          Pos Pred Value : 0.5610          
##          Neg Pred Value : 0.5347          
##              Prevalence : 0.4930          
##          Detection Rate : 0.1620          
##    Detection Prevalence : 0.2887          
##       Balanced Accuracy : 0.5393          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_4A.1_pred <- predict(smile__svm_model_4A, tst_smile_boys)
summary(smile__svm_model_4A.1_pred)
## spontaneous deliberate  
##          17          60
smile__svm_model_4A.1_confM <- confusionMatrix(
  smile__svm_model_4A.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_4A.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          10           7
##   deliberate           27          33
##                                           
##                Accuracy : 0.5584          
##                  95% CI : (0.4407, 0.6716)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.28475         
##                                           
##                   Kappa : 0.0972          
##                                           
##  Mcnemar's Test P-Value : 0.00112         
##                                           
##             Sensitivity : 0.2703          
##             Specificity : 0.8250          
##          Pos Pred Value : 0.5882          
##          Neg Pred Value : 0.5500          
##              Prevalence : 0.4805          
##          Detection Rate : 0.1299          
##    Detection Prevalence : 0.2208          
##       Balanced Accuracy : 0.5476          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_4A.2_pred <- predict(smile__svm_model_4A, tst_smile_girls)
summary(smile__svm_model_4A.2_pred)
## spontaneous deliberate  
##          24          41
smile__svm_model_4A.2_confM <- confusionMatrix(
  smile__svm_model_4A.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_4A.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          13          11
##   deliberate           20          21
##                                           
##                Accuracy : 0.5231          
##                  95% CI : (0.3954, 0.6485)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.4510          
##                                           
##                   Kappa : 0.05            
##                                           
##  Mcnemar's Test P-Value : 0.1508          
##                                           
##             Sensitivity : 0.3939          
##             Specificity : 0.6562          
##          Pos Pred Value : 0.5417          
##          Neg Pred Value : 0.5122          
##              Prevalence : 0.5077          
##          Detection Rate : 0.2000          
##    Detection Prevalence : 0.3692          
##       Balanced Accuracy : 0.5251          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 4B AU best model
set.seed(1973)
smile__svm_model_4B <- train(smile_type ~ AU01_r_mean + AU09_r_mean +
  AU10_r_mean + AU25_r_mean + AU45_r_mean,
method = "svmLinear",
data = trn_smile,
trControl = trainControl(
  method = "cv",
  number = 10
)
)

smile__svm_model_4B$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.6304089 0.2607284 0.05916065 0.1174346
summary(smile__svm_model_4B$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_4B_pred <- predict(smile__svm_model_4B, tst_smile)
summary(smile__svm_model_4B_pred)
## spontaneous deliberate  
##          63          79
smile__svm_model_4B_confM <- confusionMatrix(
  smile__svm_model_4B_pred,
  tst_smile$smile_type
)
smile__svm_model_4B_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          41          22
##   deliberate           29          50
##                                           
##                Accuracy : 0.6408          
##                  95% CI : (0.5561, 0.7196)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.0008891       
##                                           
##                   Kappa : 0.2805          
##                                           
##  Mcnemar's Test P-Value : 0.4008142       
##                                           
##             Sensitivity : 0.5857          
##             Specificity : 0.6944          
##          Pos Pred Value : 0.6508          
##          Neg Pred Value : 0.6329          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2887          
##    Detection Prevalence : 0.4437          
##       Balanced Accuracy : 0.6401          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_4B.1_pred <- predict(smile__svm_model_4B, tst_smile_boys)
summary(smile__svm_model_4B.1_pred)
## spontaneous deliberate  
##          26          51
smile__svm_model_4B.1_confM <- confusionMatrix(
  smile__svm_model_4B.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_4B.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          20           6
##   deliberate           17          34
##                                           
##                Accuracy : 0.7013          
##                  95% CI : (0.5862, 0.8003)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.0008966       
##                                           
##                   Kappa : 0.3949          
##                                           
##  Mcnemar's Test P-Value : 0.0370562       
##                                           
##             Sensitivity : 0.5405          
##             Specificity : 0.8500          
##          Pos Pred Value : 0.7692          
##          Neg Pred Value : 0.6667          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2597          
##    Detection Prevalence : 0.3377          
##       Balanced Accuracy : 0.6953          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_4B.2_pred <- predict(smile__svm_model_4B, tst_smile_girls)
summary(smile__svm_model_4B.2_pred)
## spontaneous deliberate  
##          37          28
smile__svm_model_4B.2_confM <- confusionMatrix(
  smile__svm_model_4B.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_4B.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          21          16
##   deliberate           12          16
##                                           
##                Accuracy : 0.5692          
##                  95% CI : (0.4404, 0.6915)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.1927          
##                                           
##                   Kappa : 0.1366          
##                                           
##  Mcnemar's Test P-Value : 0.5708          
##                                           
##             Sensitivity : 0.6364          
##             Specificity : 0.5000          
##          Pos Pred Value : 0.5676          
##          Neg Pred Value : 0.5714          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3231          
##    Detection Prevalence : 0.5692          
##       Balanced Accuracy : 0.5682          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 4C AU happiness model + blink
set.seed(1973)
smile__svm_model_4C <- train(smile_type ~ AU45_r_mean + AU06_r_mean +
  AU12_r_mean,
method = "svmLinear",
data = trn_smile,
trControl = trainControl(
  method = "cv",
  number = 10
)
)

smile__svm_model_4C$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.5854947 0.1737161  0.0594244 0.1205028
summary(smile__svm_model_4C$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_4C_pred <- predict(smile__svm_model_4C, tst_smile)
summary(smile__svm_model_4C_pred)
## spontaneous deliberate  
##          99          43
smile__svm_model_4C_confM <- confusionMatrix(
  smile__svm_model_4C_pred,
  tst_smile$smile_type
)
smile__svm_model_4C_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          52          47
##   deliberate           18          25
##                                           
##                Accuracy : 0.5423          
##                  95% CI : (0.4567, 0.6261)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.2251326       
##                                           
##                   Kappa : 0.0896          
##                                           
##  Mcnemar's Test P-Value : 0.0005147       
##                                           
##             Sensitivity : 0.7429          
##             Specificity : 0.3472          
##          Pos Pred Value : 0.5253          
##          Neg Pred Value : 0.5814          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3662          
##    Detection Prevalence : 0.6972          
##       Balanced Accuracy : 0.5450          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_4C.1_pred <- predict(smile__svm_model_4C, tst_smile_boys)
summary(smile__svm_model_4C.1_pred)
## spontaneous deliberate  
##          50          27
smile__svm_model_4C.1_confM <- confusionMatrix(
  smile__svm_model_4C.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_4C.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          26          24
##   deliberate           11          16
##                                           
##                Accuracy : 0.5455          
##                  95% CI : (0.4279, 0.6594)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.36674         
##                                           
##                   Kappa : 0.1014          
##                                           
##  Mcnemar's Test P-Value : 0.04252         
##                                           
##             Sensitivity : 0.7027          
##             Specificity : 0.4000          
##          Pos Pred Value : 0.5200          
##          Neg Pred Value : 0.5926          
##              Prevalence : 0.4805          
##          Detection Rate : 0.3377          
##    Detection Prevalence : 0.6494          
##       Balanced Accuracy : 0.5514          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_4C.2_pred <- predict(smile__svm_model_4C, tst_smile_girls)
summary(smile__svm_model_4C.2_pred)
## spontaneous deliberate  
##          49          16
smile__svm_model_4C.2_confM <- confusionMatrix(
  smile__svm_model_4C.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_4C.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          26          23
##   deliberate            7           9
##                                          
##                Accuracy : 0.5385         
##                  95% CI : (0.4103, 0.663)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.35525        
##                                          
##                   Kappa : 0.0697         
##                                          
##  Mcnemar's Test P-Value : 0.00617        
##                                          
##             Sensitivity : 0.7879         
##             Specificity : 0.2812         
##          Pos Pred Value : 0.5306         
##          Neg Pred Value : 0.5625         
##              Prevalence : 0.5077         
##          Detection Rate : 0.4000         
##    Detection Prevalence : 0.7538         
##       Balanced Accuracy : 0.5346         
##                                          
##        'Positive' Class : spontaneous    
## 
# model 4D AU45
set.seed(1973)
smile__svm_model_4D <-
  train(smile_type ~ AU45_r_mean,
    method = "svmLinear", data = trn_smile,
    trControl = trainControl(method = "cv", number = 10)
  )

smile__svm_model_4D$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.5853164 0.1741181 0.05423172 0.1090408
summary(smile__svm_model_4D$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_4D_pred <- predict(smile__svm_model_4D, tst_smile)
summary(smile__svm_model_4D_pred)
## spontaneous deliberate  
##          96          46
smile__svm_model_4D_confM <- confusionMatrix(
  smile__svm_model_4D_pred,
  tst_smile$smile_type
)
smile__svm_model_4D_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          49          47
##   deliberate           21          25
##                                           
##                Accuracy : 0.5211          
##                  95% CI : (0.4358, 0.6056)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.400803        
##                                           
##                   Kappa : 0.047           
##                                           
##  Mcnemar's Test P-Value : 0.002432        
##                                           
##             Sensitivity : 0.7000          
##             Specificity : 0.3472          
##          Pos Pred Value : 0.5104          
##          Neg Pred Value : 0.5435          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3451          
##    Detection Prevalence : 0.6761          
##       Balanced Accuracy : 0.5236          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_4D.1_pred <- predict(smile__svm_model_4D, tst_smile_boys)
summary(smile__svm_model_4D.1_pred)
## spontaneous deliberate  
##          51          26
smile__svm_model_4D.1_confM <- confusionMatrix(
  smile__svm_model_4D.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_4D.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          25          26
##   deliberate           12          14
##                                         
##                Accuracy : 0.5065        
##                  95% CI : (0.39, 0.6224)
##     No Information Rate : 0.5195        
##     P-Value [Acc > NIR] : 0.63425       
##                                         
##                   Kappa : 0.0253        
##                                         
##  Mcnemar's Test P-Value : 0.03496       
##                                         
##             Sensitivity : 0.6757        
##             Specificity : 0.3500        
##          Pos Pred Value : 0.4902        
##          Neg Pred Value : 0.5385        
##              Prevalence : 0.4805        
##          Detection Rate : 0.3247        
##    Detection Prevalence : 0.6623        
##       Balanced Accuracy : 0.5128        
##                                         
##        'Positive' Class : spontaneous   
## 
set.seed(1973)
smile__svm_model_4D.2_pred <- predict(smile__svm_model_4D, tst_smile_girls)
summary(smile__svm_model_4D.2_pred)
## spontaneous deliberate  
##          45          20
smile__svm_model_4D.2_confM <- confusionMatrix(
  smile__svm_model_4D.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_4D.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          24          21
##   deliberate            9          11
##                                          
##                Accuracy : 0.5385         
##                  95% CI : (0.4103, 0.663)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.35525        
##                                          
##                   Kappa : 0.0714         
##                                          
##  Mcnemar's Test P-Value : 0.04461        
##                                          
##             Sensitivity : 0.7273         
##             Specificity : 0.3438         
##          Pos Pred Value : 0.5333         
##          Neg Pred Value : 0.5500         
##              Prevalence : 0.5077         
##          Detection Rate : 0.3692         
##    Detection Prevalence : 0.6923         
##       Balanced Accuracy : 0.5355         
##                                          
##        'Positive' Class : spontaneous    
## 
# model 4E AU12
set.seed(1973)
smile__svm_model_4E <-
  train(smile_type ~ AU12_r_mean,
    method = "svmLinear",
    data = trn_smile, trControl = trainControl(method = "cv", number = 10)
  )

smile__svm_model_4E$results
##   C  Accuracy      Kappa AccuracySD   KappaSD
## 1 1 0.5399287 0.08094986 0.05983632 0.1207807
summary(smile__svm_model_4E$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_4E_pred <- predict(smile__svm_model_4E, tst_smile)
summary(smile__svm_model_4E_pred)
## spontaneous deliberate  
##          55          87
smile__svm_model_4E_confM <- confusionMatrix(
  smile__svm_model_4E_pred,
  tst_smile$smile_type
)
smile__svm_model_4E_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          28          27
##   deliberate           42          45
##                                           
##                Accuracy : 0.5141          
##                  95% CI : (0.4288, 0.5987)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.46673         
##                                           
##                   Kappa : 0.0251          
##                                           
##  Mcnemar's Test P-Value : 0.09191         
##                                           
##             Sensitivity : 0.4000          
##             Specificity : 0.6250          
##          Pos Pred Value : 0.5091          
##          Neg Pred Value : 0.5172          
##              Prevalence : 0.4930          
##          Detection Rate : 0.1972          
##    Detection Prevalence : 0.3873          
##       Balanced Accuracy : 0.5125          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_4E.1_pred <- predict(smile__svm_model_4E, tst_smile_boys)
summary(smile__svm_model_4E.1_pred)
## spontaneous deliberate  
##          20          57
smile__svm_model_4E.1_confM <- confusionMatrix(
  smile__svm_model_4E.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_4E.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          12           8
##   deliberate           25          32
##                                           
##                Accuracy : 0.5714          
##                  95% CI : (0.4535, 0.6837)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.212593        
##                                           
##                   Kappa : 0.1265          
##                                           
##  Mcnemar's Test P-Value : 0.005349        
##                                           
##             Sensitivity : 0.3243          
##             Specificity : 0.8000          
##          Pos Pred Value : 0.6000          
##          Neg Pred Value : 0.5614          
##              Prevalence : 0.4805          
##          Detection Rate : 0.1558          
##    Detection Prevalence : 0.2597          
##       Balanced Accuracy : 0.5622          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_4E.2_pred <- predict(smile__svm_model_4E, tst_smile_girls)
summary(smile__svm_model_4E.2_pred)
## spontaneous deliberate  
##          35          30
smile__svm_model_4E.2_confM <- confusionMatrix(
  smile__svm_model_4E.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_4E.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          16          19
##   deliberate           17          13
##                                           
##                Accuracy : 0.4462          
##                  95% CI : (0.3227, 0.5747)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.8679          
##                                           
##                   Kappa : -0.109          
##                                           
##  Mcnemar's Test P-Value : 0.8676          
##                                           
##             Sensitivity : 0.4848          
##             Specificity : 0.4062          
##          Pos Pred Value : 0.4571          
##          Neg Pred Value : 0.4333          
##              Prevalence : 0.5077          
##          Detection Rate : 0.2462          
##    Detection Prevalence : 0.5385          
##       Balanced Accuracy : 0.4455          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 4F AU06
set.seed(1973)
smile__svm_model_4F <-
  train(smile_type ~ AU06_r_mean,
    method = "svmLinear",
    data = trn_smile, trControl = trainControl(method = "cv", number = 10)
  )

smile__svm_model_4F$results
##   C  Accuracy      Kappa AccuracySD   KappaSD
## 1 1 0.5487411 0.09600249 0.07076652 0.1449534
summary(smile__svm_model_4F$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_4F_pred <- predict(smile__svm_model_4F, tst_smile)
summary(smile__svm_model_4F_pred)
## spontaneous deliberate  
##          44          98
smile__svm_model_4F_confM <- confusionMatrix(
  smile__svm_model_4F_pred,
  tst_smile$smile_type
)
smile__svm_model_4F_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          24          20
##   deliberate           46          52
##                                           
##                Accuracy : 0.5352          
##                  95% CI : (0.4497, 0.6193)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.278603        
##                                           
##                   Kappa : 0.0654          
##                                           
##  Mcnemar's Test P-Value : 0.002089        
##                                           
##             Sensitivity : 0.3429          
##             Specificity : 0.7222          
##          Pos Pred Value : 0.5455          
##          Neg Pred Value : 0.5306          
##              Prevalence : 0.4930          
##          Detection Rate : 0.1690          
##    Detection Prevalence : 0.3099          
##       Balanced Accuracy : 0.5325          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_4F.1_pred <- predict(smile__svm_model_4F, tst_smile_boys)
summary(smile__svm_model_4F.1_pred)
## spontaneous deliberate  
##          17          60
smile__svm_model_4F.1_confM <- confusionMatrix(
  smile__svm_model_4F.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_4F.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          10           7
##   deliberate           27          33
##                                           
##                Accuracy : 0.5584          
##                  95% CI : (0.4407, 0.6716)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.28475         
##                                           
##                   Kappa : 0.0972          
##                                           
##  Mcnemar's Test P-Value : 0.00112         
##                                           
##             Sensitivity : 0.2703          
##             Specificity : 0.8250          
##          Pos Pred Value : 0.5882          
##          Neg Pred Value : 0.5500          
##              Prevalence : 0.4805          
##          Detection Rate : 0.1299          
##    Detection Prevalence : 0.2208          
##       Balanced Accuracy : 0.5476          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_4F.2_pred <- predict(smile__svm_model_4F, tst_smile_girls)
summary(smile__svm_model_4F.2_pred)
## spontaneous deliberate  
##          27          38
smile__svm_model_4F.2_confM <- confusionMatrix(
  smile__svm_model_4F.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_4F.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          14          13
##   deliberate           19          19
##                                          
##                Accuracy : 0.5077         
##                  95% CI : (0.3807, 0.634)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.5495         
##                                          
##                   Kappa : 0.0179         
##                                          
##  Mcnemar's Test P-Value : 0.3768         
##                                          
##             Sensitivity : 0.4242         
##             Specificity : 0.5938         
##          Pos Pred Value : 0.5185         
##          Neg Pred Value : 0.5000         
##              Prevalence : 0.5077         
##          Detection Rate : 0.2154         
##    Detection Prevalence : 0.4154         
##       Balanced Accuracy : 0.5090         
##                                          
##        'Positive' Class : spontaneous    
## 
# model 4G AU10
set.seed(1973)
smile__svm_model_4G <-
  train(smile_type ~ AU10_r_mean,
    method = "svmLinear", data = trn_smile,
    trControl = trainControl(method = "cv", number = 10)
  )

smile__svm_model_4G$results
##   C Accuracy     Kappa AccuracySD   KappaSD
## 1 1   0.5729 0.1451991 0.08629806 0.1728594
summary(smile__svm_model_4G$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_4G_pred <- predict(smile__svm_model_4G, tst_smile)
summary(smile__svm_model_4G_pred)
## spontaneous deliberate  
##          52          90
smile__svm_model_4G_confM <- confusionMatrix(
  smile__svm_model_4G_pred,
  tst_smile$smile_type
)
smile__svm_model_4G_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          29          23
##   deliberate           41          49
##                                           
##                Accuracy : 0.5493          
##                  95% CI : (0.4636, 0.6328)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.17799         
##                                           
##                   Kappa : 0.0952          
##                                           
##  Mcnemar's Test P-Value : 0.03359         
##                                           
##             Sensitivity : 0.4143          
##             Specificity : 0.6806          
##          Pos Pred Value : 0.5577          
##          Neg Pred Value : 0.5444          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2042          
##    Detection Prevalence : 0.3662          
##       Balanced Accuracy : 0.5474          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_4G.1_pred <- predict(smile__svm_model_4G, tst_smile_boys)
summary(smile__svm_model_4G.1_pred)
## spontaneous deliberate  
##          19          58
smile__svm_model_4G.1_confM <- confusionMatrix(
  smile__svm_model_4G.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_4G.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          13           6
##   deliberate           24          34
##                                           
##                Accuracy : 0.6104          
##                  95% CI : (0.4925, 0.7195)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.068593        
##                                           
##                   Kappa : 0.2051          
##                                           
##  Mcnemar's Test P-Value : 0.001911        
##                                           
##             Sensitivity : 0.3514          
##             Specificity : 0.8500          
##          Pos Pred Value : 0.6842          
##          Neg Pred Value : 0.5862          
##              Prevalence : 0.4805          
##          Detection Rate : 0.1688          
##    Detection Prevalence : 0.2468          
##       Balanced Accuracy : 0.6007          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_4G.2_pred <- predict(smile__svm_model_4G, tst_smile_girls)
summary(smile__svm_model_4G.2_pred)
## spontaneous deliberate  
##          33          32
smile__svm_model_4G.2_confM <- confusionMatrix(
  smile__svm_model_4G.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_4G.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          16          17
##   deliberate           17          15
##                                           
##                Accuracy : 0.4769          
##                  95% CI : (0.3515, 0.6046)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.7324          
##                                           
##                   Kappa : -0.0464         
##                                           
##  Mcnemar's Test P-Value : 1.0000          
##                                           
##             Sensitivity : 0.4848          
##             Specificity : 0.4688          
##          Pos Pred Value : 0.4848          
##          Neg Pred Value : 0.4688          
##              Prevalence : 0.5077          
##          Detection Rate : 0.2462          
##    Detection Prevalence : 0.5077          
##       Balanced Accuracy : 0.4768          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 4H AU01
set.seed(1973)
smile__svm_model_4H <-
  train(smile_type ~ AU01_r_mean,
    method = "svmLinear",
    data = trn_smile, trControl = trainControl(method = "cv", number = 10)
  )

smile__svm_model_4H$results
##   C  Accuracy      Kappa AccuracySD   KappaSD
## 1 1 0.5350546 0.07469541 0.08066542 0.1592671
summary(smile__svm_model_4H$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_4H_pred <- predict(smile__svm_model_4H, tst_smile)
summary(smile__svm_model_4H_pred)
## spontaneous deliberate  
##         115          27
smile__svm_model_4H_confM <- confusionMatrix(
  smile__svm_model_4H_pred,
  tst_smile$smile_type
)
smile__svm_model_4H_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          60          55
##   deliberate           10          17
##                                           
##                Accuracy : 0.5423          
##                  95% CI : (0.4567, 0.6261)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.2251          
##                                           
##                   Kappa : 0.0924          
##                                           
##  Mcnemar's Test P-Value : 4.828e-08       
##                                           
##             Sensitivity : 0.8571          
##             Specificity : 0.2361          
##          Pos Pred Value : 0.5217          
##          Neg Pred Value : 0.6296          
##              Prevalence : 0.4930          
##          Detection Rate : 0.4225          
##    Detection Prevalence : 0.8099          
##       Balanced Accuracy : 0.5466          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_4H.1_pred <- predict(smile__svm_model_4H, tst_smile_boys)
summary(smile__svm_model_4H.1_pred)
## spontaneous deliberate  
##          65          12
smile__svm_model_4H.1_confM <- confusionMatrix(
  smile__svm_model_4H.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_4H.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          34          31
##   deliberate            3           9
##                                           
##                Accuracy : 0.5584          
##                  95% CI : (0.4407, 0.6716)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.2847          
##                                           
##                   Kappa : 0.1399          
##                                           
##  Mcnemar's Test P-Value : 3.649e-06       
##                                           
##             Sensitivity : 0.9189          
##             Specificity : 0.2250          
##          Pos Pred Value : 0.5231          
##          Neg Pred Value : 0.7500          
##              Prevalence : 0.4805          
##          Detection Rate : 0.4416          
##    Detection Prevalence : 0.8442          
##       Balanced Accuracy : 0.5720          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_4H.2_pred <- predict(smile__svm_model_4H, tst_smile_girls)
summary(smile__svm_model_4H.2_pred)
## spontaneous deliberate  
##          50          15
smile__svm_model_4H.2_confM <- confusionMatrix(
  smile__svm_model_4H.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_4H.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          26          24
##   deliberate            7           8
##                                           
##                Accuracy : 0.5231          
##                  95% CI : (0.3954, 0.6485)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.450951        
##                                           
##                   Kappa : 0.0382          
##                                           
##  Mcnemar's Test P-Value : 0.004057        
##                                           
##             Sensitivity : 0.7879          
##             Specificity : 0.2500          
##          Pos Pred Value : 0.5200          
##          Neg Pred Value : 0.5333          
##              Prevalence : 0.5077          
##          Detection Rate : 0.4000          
##    Detection Prevalence : 0.7692          
##       Balanced Accuracy : 0.5189          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 4I AU25
set.seed(1973)
smile__svm_model_4I <-
  train(smile_type ~ AU25_r_mean,
    method = "svmLinear",
    data = trn_smile,
    trControl = trainControl(method = "cv", number = 10)
  )

smile__svm_model_4I$results
##   C  Accuracy    Kappa AccuracySD    KappaSD
## 1 1 0.5705158 0.143362 0.04911462 0.09427582
summary(smile__svm_model_4I$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_4I_pred <- predict(smile__svm_model_4I, tst_smile)
summary(smile__svm_model_4I_pred)
## spontaneous deliberate  
##         106          36
smile__svm_model_4I_confM <- confusionMatrix(
  smile__svm_model_4I_pred,
  tst_smile$smile_type
)
smile__svm_model_4I_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          60          46
##   deliberate           10          26
##                                           
##                Accuracy : 0.6056          
##                  95% CI : (0.5202, 0.6865)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.01151         
##                                           
##                   Kappa : 0.2167          
##                                           
##  Mcnemar's Test P-Value : 2.91e-06        
##                                           
##             Sensitivity : 0.8571          
##             Specificity : 0.3611          
##          Pos Pred Value : 0.5660          
##          Neg Pred Value : 0.7222          
##              Prevalence : 0.4930          
##          Detection Rate : 0.4225          
##    Detection Prevalence : 0.7465          
##       Balanced Accuracy : 0.6091          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_4I.1_pred <- predict(smile__svm_model_4I, tst_smile_boys)
summary(smile__svm_model_4I.1_pred)
## spontaneous deliberate  
##          62          15
smile__svm_model_4I.1_confM <- confusionMatrix(
  smile__svm_model_4I.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_4I.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          34          28
##   deliberate            3          12
##                                           
##                Accuracy : 0.5974          
##                  95% CI : (0.4794, 0.7077)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.1045          
##                                           
##                   Kappa : 0.2135          
##                                           
##  Mcnemar's Test P-Value : 1.629e-05       
##                                           
##             Sensitivity : 0.9189          
##             Specificity : 0.3000          
##          Pos Pred Value : 0.5484          
##          Neg Pred Value : 0.8000          
##              Prevalence : 0.4805          
##          Detection Rate : 0.4416          
##    Detection Prevalence : 0.8052          
##       Balanced Accuracy : 0.6095          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_4I.2_pred <- predict(smile__svm_model_4I, tst_smile_girls)
summary(smile__svm_model_4I.2_pred)
## spontaneous deliberate  
##          44          21
smile__svm_model_4I.2_confM <- confusionMatrix(
  smile__svm_model_4I.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_4I.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          26          18
##   deliberate            7          14
##                                           
##                Accuracy : 0.6154          
##                  95% CI : (0.4864, 0.7335)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.05294         
##                                           
##                   Kappa : 0.2266          
##                                           
##  Mcnemar's Test P-Value : 0.04550         
##                                           
##             Sensitivity : 0.7879          
##             Specificity : 0.4375          
##          Pos Pred Value : 0.5909          
##          Neg Pred Value : 0.6667          
##              Prevalence : 0.5077          
##          Detection Rate : 0.4000          
##    Detection Prevalence : 0.6769          
##       Balanced Accuracy : 0.6127          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 4J AU09
set.seed(1973)
smile__svm_model_4J <-
  train(smile_type ~ AU09_r_mean,
    method = "svmLinear",
    data = trn_smile, trControl = trainControl(method = "cv", number = 10)
  )

smile__svm_model_4J$results
##   C  Accuracy      Kappa AccuracySD   KappaSD
## 1 1 0.5249276 0.04510716 0.08572585 0.1669863
summary(smile__svm_model_4J$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_4J_pred <- predict(smile__svm_model_4J, tst_smile)
summary(smile__svm_model_4J_pred)
## spontaneous deliberate  
##          30         112
smile__svm_model_4J_confM <- confusionMatrix(
  smile__svm_model_4J_pred,
  tst_smile$smile_type
)
smile__svm_model_4J_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          12          18
##   deliberate           58          54
##                                           
##                Accuracy : 0.4648          
##                  95% CI : (0.3807, 0.5503)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.8624          
##                                           
##                   Kappa : -0.0792         
##                                           
##  Mcnemar's Test P-Value : 7.691e-06       
##                                           
##             Sensitivity : 0.17143         
##             Specificity : 0.75000         
##          Pos Pred Value : 0.40000         
##          Neg Pred Value : 0.48214         
##              Prevalence : 0.49296         
##          Detection Rate : 0.08451         
##    Detection Prevalence : 0.21127         
##       Balanced Accuracy : 0.46071         
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_4J.1_pred <- predict(smile__svm_model_4J, tst_smile_boys)
summary(smile__svm_model_4J.1_pred)
## spontaneous deliberate  
##          16          61
smile__svm_model_4J.1_confM <- confusionMatrix(
  smile__svm_model_4J.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_4J.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           6          10
##   deliberate           31          30
##                                           
##                Accuracy : 0.4675          
##                  95% CI : (0.3529, 0.5848)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.847647        
##                                           
##                   Kappa : -0.0897         
##                                           
##  Mcnemar's Test P-Value : 0.001787        
##                                           
##             Sensitivity : 0.16216         
##             Specificity : 0.75000         
##          Pos Pred Value : 0.37500         
##          Neg Pred Value : 0.49180         
##              Prevalence : 0.48052         
##          Detection Rate : 0.07792         
##    Detection Prevalence : 0.20779         
##       Balanced Accuracy : 0.45608         
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_4J.2_pred <- predict(smile__svm_model_4J, tst_smile_girls)
summary(smile__svm_model_4J.2_pred)
## spontaneous deliberate  
##          14          51
smile__svm_model_4J.2_confM <- confusionMatrix(
  smile__svm_model_4J.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_4J.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous           6           8
##   deliberate           27          24
##                                          
##                Accuracy : 0.4615         
##                  95% CI : (0.337, 0.5897)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.807360       
##                                          
##                   Kappa : -0.0676        
##                                          
##  Mcnemar's Test P-Value : 0.002346       
##                                          
##             Sensitivity : 0.18182        
##             Specificity : 0.75000        
##          Pos Pred Value : 0.42857        
##          Neg Pred Value : 0.47059        
##              Prevalence : 0.50769        
##          Detection Rate : 0.09231        
##    Detection Prevalence : 0.21538        
##       Balanced Accuracy : 0.46591        
##                                          
##        'Positive' Class : spontaneous    
## 
# model 5 head pose features
set.seed(1973)
smile__svm_model_5 <-
  train(smile_type ~ pose_Rx_mean + pose_Ry_mean + pose_Rz_mean,
    method = "svmLinear", data = trn_smile,
    trControl = trainControl(method = "cv", number = 10)
  )

smile__svm_model_5$results
##   C  Accuracy       Kappa AccuracySD   KappaSD
## 1 1 0.4505236 -0.09969948 0.06191438 0.1240377
summary(smile__svm_model_5$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_5_pred <- predict(smile__svm_model_5, tst_smile)
summary(smile__svm_model_5_pred)
## spontaneous deliberate  
##          62          80
smile__svm_model_5_confM <- confusionMatrix(
  smile__svm_model_5_pred,
  tst_smile$smile_type
)
smile__svm_model_5_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          31          31
##   deliberate           39          41
##                                           
##                Accuracy : 0.507           
##                  95% CI : (0.4219, 0.5919)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.5336          
##                                           
##                   Kappa : 0.0123          
##                                           
##  Mcnemar's Test P-Value : 0.4028          
##                                           
##             Sensitivity : 0.4429          
##             Specificity : 0.5694          
##          Pos Pred Value : 0.5000          
##          Neg Pred Value : 0.5125          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2183          
##    Detection Prevalence : 0.4366          
##       Balanced Accuracy : 0.5062          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_5.1_pred <- predict(smile__svm_model_5, tst_smile_boys)
summary(smile__svm_model_5.1_pred)
## spontaneous deliberate  
##          31          46
smile__svm_model_5.1_confM <- confusionMatrix(
  smile__svm_model_5.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_5.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          15          16
##   deliberate           22          24
##                                         
##                Accuracy : 0.5065        
##                  95% CI : (0.39, 0.6224)
##     No Information Rate : 0.5195        
##     P-Value [Acc > NIR] : 0.6342        
##                                         
##                   Kappa : 0.0054        
##                                         
##  Mcnemar's Test P-Value : 0.4173        
##                                         
##             Sensitivity : 0.4054        
##             Specificity : 0.6000        
##          Pos Pred Value : 0.4839        
##          Neg Pred Value : 0.5217        
##              Prevalence : 0.4805        
##          Detection Rate : 0.1948        
##    Detection Prevalence : 0.4026        
##       Balanced Accuracy : 0.5027        
##                                         
##        'Positive' Class : spontaneous   
## 
set.seed(1973)
smile__svm_model_5.2_pred <- predict(smile__svm_model_5, tst_smile_girls)
summary(smile__svm_model_5.2_pred)
## spontaneous deliberate  
##          31          34
smile__svm_model_5.2_confM <- confusionMatrix(
  smile__svm_model_5.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_5.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          16          15
##   deliberate           17          17
##                                          
##                Accuracy : 0.5077         
##                  95% CI : (0.3807, 0.634)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.5495         
##                                          
##                   Kappa : 0.0161         
##                                          
##  Mcnemar's Test P-Value : 0.8597         
##                                          
##             Sensitivity : 0.4848         
##             Specificity : 0.5312         
##          Pos Pred Value : 0.5161         
##          Neg Pred Value : 0.5000         
##              Prevalence : 0.5077         
##          Detection Rate : 0.2462         
##    Detection Prevalence : 0.4769         
##       Balanced Accuracy : 0.5080         
##                                          
##        'Positive' Class : spontaneous    
## 
# model 5A gaze features
set.seed(1973)
smile__svm_model_5A <- train(smile_type ~ gaze_angle_x_mean + gaze_angle_y_mean,
  method = "svmLinear", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_5A$results
##   C  Accuracy       Kappa AccuracySD    KappaSD
## 1 1 0.4712901 -0.05969345 0.04430412 0.08370863
summary(smile__svm_model_5A$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_5A_pred <- predict(smile__svm_model_5A, tst_smile)
summary(smile__svm_model_5A_pred)
## spontaneous deliberate  
##          41         101
smile__svm_model_5A_confM <- confusionMatrix(
  smile__svm_model_5A_pred,
  tst_smile$smile_type
)
smile__svm_model_5A_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          30          11
##   deliberate           40          61
##                                           
##                Accuracy : 0.6408          
##                  95% CI : (0.5561, 0.7196)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.0008891       
##                                           
##                   Kappa : 0.2774          
##                                           
##  Mcnemar's Test P-Value : 8.826e-05       
##                                           
##             Sensitivity : 0.4286          
##             Specificity : 0.8472          
##          Pos Pred Value : 0.7317          
##          Neg Pred Value : 0.6040          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2113          
##    Detection Prevalence : 0.2887          
##       Balanced Accuracy : 0.6379          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_5A.1_pred <- predict(smile__svm_model_5A, tst_smile_boys)
summary(smile__svm_model_5A.1_pred)
## spontaneous deliberate  
##          27          50
smile__svm_model_5A.1_confM <- confusionMatrix(
  smile__svm_model_5A.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_5A.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          18           9
##   deliberate           19          31
##                                          
##                Accuracy : 0.6364         
##                  95% CI : (0.5188, 0.743)
##     No Information Rate : 0.5195         
##     P-Value [Acc > NIR] : 0.02565        
##                                          
##                   Kappa : 0.2642         
##                                          
##  Mcnemar's Test P-Value : 0.08897        
##                                          
##             Sensitivity : 0.4865         
##             Specificity : 0.7750         
##          Pos Pred Value : 0.6667         
##          Neg Pred Value : 0.6200         
##              Prevalence : 0.4805         
##          Detection Rate : 0.2338         
##    Detection Prevalence : 0.3506         
##       Balanced Accuracy : 0.6307         
##                                          
##        'Positive' Class : spontaneous    
## 
set.seed(1973)
smile__svm_model_5A.2_pred <- predict(smile__svm_model_5A, tst_smile_girls)
summary(smile__svm_model_5A.2_pred)
## spontaneous deliberate  
##          14          51
smile__svm_model_5A.2_confM <- confusionMatrix(
  smile__svm_model_5A.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_5A.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          12           2
##   deliberate           21          30
##                                           
##                Accuracy : 0.6462          
##                  95% CI : (0.5177, 0.7608)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.0169758       
##                                           
##                   Kappa : 0.2985          
##                                           
##  Mcnemar's Test P-Value : 0.0001746       
##                                           
##             Sensitivity : 0.3636          
##             Specificity : 0.9375          
##          Pos Pred Value : 0.8571          
##          Neg Pred Value : 0.5882          
##              Prevalence : 0.5077          
##          Detection Rate : 0.1846          
##    Detection Prevalence : 0.2154          
##       Balanced Accuracy : 0.6506          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 5B gaze + head pose features
set.seed(1973)
smile__svm_model_5B <-
  train(smile_type ~ pose_Rx_mean + pose_Ry_mean + pose_Rz_mean +
    gaze_angle_x_mean + gaze_angle_y_mean,
  method = "svmLinear", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
  )

smile__svm_model_5B$results
##   C  Accuracy       Kappa AccuracySD  KappaSD
## 1 1 0.4737745 -0.05205384  0.0817408 0.162664
summary(smile__svm_model_5B$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_5B_pred <- predict(smile__svm_model_5B, tst_smile)
summary(smile__svm_model_5B_pred)
## spontaneous deliberate  
##          55          87
smile__svm_model_5B_confM <- confusionMatrix(
  smile__svm_model_5B_pred,
  tst_smile$smile_type
)
smile__svm_model_5B_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          31          24
##   deliberate           39          48
##                                           
##                Accuracy : 0.5563          
##                  95% CI : (0.4707, 0.6396)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.13758         
##                                           
##                   Kappa : 0.1099          
##                                           
##  Mcnemar's Test P-Value : 0.07776         
##                                           
##             Sensitivity : 0.4429          
##             Specificity : 0.6667          
##          Pos Pred Value : 0.5636          
##          Neg Pred Value : 0.5517          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2183          
##    Detection Prevalence : 0.3873          
##       Balanced Accuracy : 0.5548          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_5B.1_pred <- predict(smile__svm_model_5B, tst_smile_boys)
summary(smile__svm_model_5B.1_pred)
## spontaneous deliberate  
##          30          47
smile__svm_model_5B.1_confM <- confusionMatrix(
  smile__svm_model_5B.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_5B.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          14          16
##   deliberate           23          24
##                                         
##                Accuracy : 0.4935        
##                  95% CI : (0.3776, 0.61)
##     No Information Rate : 0.5195        
##     P-Value [Acc > NIR] : 0.7159        
##                                         
##                   Kappa : -0.0218       
##                                         
##  Mcnemar's Test P-Value : 0.3367        
##                                         
##             Sensitivity : 0.3784        
##             Specificity : 0.6000        
##          Pos Pred Value : 0.4667        
##          Neg Pred Value : 0.5106        
##              Prevalence : 0.4805        
##          Detection Rate : 0.1818        
##    Detection Prevalence : 0.3896        
##       Balanced Accuracy : 0.4892        
##                                         
##        'Positive' Class : spontaneous   
## 
set.seed(1973)
smile__svm_model_5B.2_pred <- predict(smile__svm_model_5B, tst_smile_girls)
summary(smile__svm_model_5B.2_pred)
## spontaneous deliberate  
##          25          40
smile__svm_model_5B.2_confM <- confusionMatrix(
  smile__svm_model_5B.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_5B.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          17           8
##   deliberate           16          24
##                                          
##                Accuracy : 0.6308         
##                  95% CI : (0.502, 0.7472)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.03086        
##                                          
##                   Kappa : 0.2642         
##                                          
##  Mcnemar's Test P-Value : 0.15304        
##                                          
##             Sensitivity : 0.5152         
##             Specificity : 0.7500         
##          Pos Pred Value : 0.6800         
##          Neg Pred Value : 0.6000         
##              Prevalence : 0.5077         
##          Detection Rate : 0.2615         
##    Detection Prevalence : 0.3846         
##       Balanced Accuracy : 0.6326         
##                                          
##        'Positive' Class : spontaneous    
## 
# model 6 dynamics and movement
set.seed(1973)
smile__svm_model_6 <-
  train(smile_type ~ onset_mean + apex_mean + offset_mean + eye_mean + lip_mean,
    method = "svmLinear", data = trn_smile,
    trControl = trainControl(method = "cv", number = 10)
  )

smile__svm_model_6$results
##   C Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.665781 0.3333057 0.08962779 0.1773316
summary(smile__svm_model_6$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_6_pred <- predict(smile__svm_model_6, tst_smile)
summary(smile__svm_model_6_pred)
## spontaneous deliberate  
##          74          68
smile__svm_model_6_confM <- confusionMatrix(
  smile__svm_model_6_pred,
  tst_smile$smile_type
)
smile__svm_model_6_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          48          26
##   deliberate           22          46
##                                           
##                Accuracy : 0.662           
##                  95% CI : (0.5779, 0.7391)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.0001362       
##                                           
##                   Kappa : 0.3243          
##                                           
##  Mcnemar's Test P-Value : 0.6650055       
##                                           
##             Sensitivity : 0.6857          
##             Specificity : 0.6389          
##          Pos Pred Value : 0.6486          
##          Neg Pred Value : 0.6765          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3380          
##    Detection Prevalence : 0.5211          
##       Balanced Accuracy : 0.6623          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_6.1_pred <- predict(smile__svm_model_6, tst_smile_boys)
summary(smile__svm_model_6.1_pred)
## spontaneous deliberate  
##          33          44
smile__svm_model_6.1_confM <- confusionMatrix(
  smile__svm_model_6.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_6.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          22          11
##   deliberate           15          29
##                                           
##                Accuracy : 0.6623          
##                  95% CI : (0.5455, 0.7662)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.007868        
##                                           
##                   Kappa : 0.3209          
##                                           
##  Mcnemar's Test P-Value : 0.556298        
##                                           
##             Sensitivity : 0.5946          
##             Specificity : 0.7250          
##          Pos Pred Value : 0.6667          
##          Neg Pred Value : 0.6591          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2857          
##    Detection Prevalence : 0.4286          
##       Balanced Accuracy : 0.6598          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_6.2_pred <- predict(smile__svm_model_6, tst_smile_girls)
summary(smile__svm_model_6.2_pred)
## spontaneous deliberate  
##          41          24
smile__svm_model_6.2_confM <- confusionMatrix(
  smile__svm_model_6.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_6.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          26          15
##   deliberate            7          17
##                                           
##                Accuracy : 0.6615          
##                  95% CI : (0.5335, 0.7743)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.008794        
##                                           
##                   Kappa : 0.3203          
##                                           
##  Mcnemar's Test P-Value : 0.135593        
##                                           
##             Sensitivity : 0.7879          
##             Specificity : 0.5312          
##          Pos Pred Value : 0.6341          
##          Neg Pred Value : 0.7083          
##              Prevalence : 0.5077          
##          Detection Rate : 0.4000          
##    Detection Prevalence : 0.6308          
##       Balanced Accuracy : 0.6596          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 6A dynamics and eye
set.seed(1973)
smile__svm_model_6A <-
  train(smile_type ~ onset_mean + apex_mean + offset_mean + eye_mean,
    method = "svmLinear", data = trn_smile,
    trControl = trainControl(method = "cv", number = 10)
  )

smile__svm_model_6A$results
##   C  Accuracy   Kappa AccuracySD   KappaSD
## 1 1 0.6509024 0.30311  0.1167325 0.2316699
summary(smile__svm_model_6A$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_6A_pred <- predict(smile__svm_model_6A, tst_smile)
summary(smile__svm_model_6A_pred)
## spontaneous deliberate  
##          78          64
smile__svm_model_6A_confM <- confusionMatrix(
  smile__svm_model_6A_pred,
  tst_smile$smile_type
)
smile__svm_model_6A_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          51          27
##   deliberate           19          45
##                                           
##                Accuracy : 0.6761          
##                  95% CI : (0.5925, 0.7521)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 3.363e-05       
##                                           
##                   Kappa : 0.353           
##                                           
##  Mcnemar's Test P-Value : 0.302           
##                                           
##             Sensitivity : 0.7286          
##             Specificity : 0.6250          
##          Pos Pred Value : 0.6538          
##          Neg Pred Value : 0.7031          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3592          
##    Detection Prevalence : 0.5493          
##       Balanced Accuracy : 0.6768          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_6A.1_pred <- predict(smile__svm_model_6A, tst_smile_boys)
summary(smile__svm_model_6A.1_pred)
## spontaneous deliberate  
##          37          40
smile__svm_model_6A.1_confM <- confusionMatrix(
  smile__svm_model_6A.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_6A.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          25          12
##   deliberate           12          28
##                                           
##                Accuracy : 0.6883          
##                  95% CI : (0.5726, 0.7891)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.001955        
##                                           
##                   Kappa : 0.3757          
##                                           
##  Mcnemar's Test P-Value : 1.000000        
##                                           
##             Sensitivity : 0.6757          
##             Specificity : 0.7000          
##          Pos Pred Value : 0.6757          
##          Neg Pred Value : 0.7000          
##              Prevalence : 0.4805          
##          Detection Rate : 0.3247          
##    Detection Prevalence : 0.4805          
##       Balanced Accuracy : 0.6878          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_6A.2_pred <- predict(smile__svm_model_6A, tst_smile_girls)
summary(smile__svm_model_6A.2_pred)
## spontaneous deliberate  
##          41          24
smile__svm_model_6A.2_confM <- confusionMatrix(
  smile__svm_model_6A.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_6A.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          26          15
##   deliberate            7          17
##                                           
##                Accuracy : 0.6615          
##                  95% CI : (0.5335, 0.7743)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.008794        
##                                           
##                   Kappa : 0.3203          
##                                           
##  Mcnemar's Test P-Value : 0.135593        
##                                           
##             Sensitivity : 0.7879          
##             Specificity : 0.5312          
##          Pos Pred Value : 0.6341          
##          Neg Pred Value : 0.7083          
##              Prevalence : 0.5077          
##          Detection Rate : 0.4000          
##    Detection Prevalence : 0.6308          
##       Balanced Accuracy : 0.6596          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 6B dynamics and lip
set.seed(1973)
smile__svm_model_6B <-
  train(smile_type ~ onset_mean + apex_mean + offset_mean + lip_mean,
    method = "svmLinear", data = trn_smile,
    trControl = trainControl(method = "cv", number = 10)
  )

smile__svm_model_6B$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.6691789 0.3392816 0.07023856 0.1394647
summary(smile__svm_model_6B$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_6B_pred <- predict(smile__svm_model_6B, tst_smile)
summary(smile__svm_model_6B_pred)
## spontaneous deliberate  
##          71          71
smile__svm_model_6B_confM <- confusionMatrix(
  smile__svm_model_6B_pred,
  tst_smile$smile_type
)
smile__svm_model_6B_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          48          23
##   deliberate           22          49
##                                           
##                Accuracy : 0.6831          
##                  95% CI : (0.5998, 0.7586)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 1.596e-05       
##                                           
##                   Kappa : 0.3662          
##                                           
##  Mcnemar's Test P-Value : 1               
##                                           
##             Sensitivity : 0.6857          
##             Specificity : 0.6806          
##          Pos Pred Value : 0.6761          
##          Neg Pred Value : 0.6901          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3380          
##    Detection Prevalence : 0.5000          
##       Balanced Accuracy : 0.6831          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_6B.1_pred <- predict(smile__svm_model_6B, tst_smile_boys)
summary(smile__svm_model_6B.1_pred)
## spontaneous deliberate  
##          33          44
smile__svm_model_6B.1_confM <- confusionMatrix(
  smile__svm_model_6B.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_6B.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          23          10
##   deliberate           14          30
##                                           
##                Accuracy : 0.6883          
##                  95% CI : (0.5726, 0.7891)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.001955        
##                                           
##                   Kappa : 0.3731          
##                                           
##  Mcnemar's Test P-Value : 0.540291        
##                                           
##             Sensitivity : 0.6216          
##             Specificity : 0.7500          
##          Pos Pred Value : 0.6970          
##          Neg Pred Value : 0.6818          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2987          
##    Detection Prevalence : 0.4286          
##       Balanced Accuracy : 0.6858          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_6B.2_pred <- predict(smile__svm_model_6B, tst_smile_girls)
summary(smile__svm_model_6B.2_pred)
## spontaneous deliberate  
##          38          27
smile__svm_model_6B.2_confM <- confusionMatrix(
  smile__svm_model_6B.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_6B.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          25          13
##   deliberate            8          19
##                                           
##                Accuracy : 0.6769          
##                  95% CI : (0.5495, 0.7877)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.004282        
##                                           
##                   Kappa : 0.3522          
##                                           
##  Mcnemar's Test P-Value : 0.382733        
##                                           
##             Sensitivity : 0.7576          
##             Specificity : 0.5938          
##          Pos Pred Value : 0.6579          
##          Neg Pred Value : 0.7037          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3846          
##    Detection Prevalence : 0.5846          
##       Balanced Accuracy : 0.6757          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 6C onset and movement
set.seed(1973)
smile__svm_model_6C <- train(smile_type ~ onset_mean + eye_mean + lip_mean,
  method = "svmLinear", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_6C$results
##   C Accuracy     Kappa AccuracySD    KappaSD
## 1 1 0.660723 0.3212148 0.04400409 0.08849735
summary(smile__svm_model_6C$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_6C_pred <- predict(smile__svm_model_6C, tst_smile)
summary(smile__svm_model_6C_pred)
## spontaneous deliberate  
##          77          65
smile__svm_model_6C_confM <- confusionMatrix(
  smile__svm_model_6C_pred,
  tst_smile$smile_type
)
smile__svm_model_6C_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          42          35
##   deliberate           28          37
##                                           
##                Accuracy : 0.5563          
##                  95% CI : (0.4707, 0.6396)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.1376          
##                                           
##                   Kappa : 0.1137          
##                                           
##  Mcnemar's Test P-Value : 0.4497          
##                                           
##             Sensitivity : 0.6000          
##             Specificity : 0.5139          
##          Pos Pred Value : 0.5455          
##          Neg Pred Value : 0.5692          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2958          
##    Detection Prevalence : 0.5423          
##       Balanced Accuracy : 0.5569          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_6C.1_pred <- predict(smile__svm_model_6C, tst_smile_boys)
summary(smile__svm_model_6C.1_pred)
## spontaneous deliberate  
##          36          41
smile__svm_model_6C.1_confM <- confusionMatrix(
  smile__svm_model_6C.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_6C.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          21          15
##   deliberate           16          25
##                                           
##                Accuracy : 0.5974          
##                  95% CI : (0.4794, 0.7077)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.1045          
##                                           
##                   Kappa : 0.1928          
##                                           
##  Mcnemar's Test P-Value : 1.0000          
##                                           
##             Sensitivity : 0.5676          
##             Specificity : 0.6250          
##          Pos Pred Value : 0.5833          
##          Neg Pred Value : 0.6098          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2727          
##    Detection Prevalence : 0.4675          
##       Balanced Accuracy : 0.5963          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_6C.2_pred <- predict(smile__svm_model_6C, tst_smile_girls)
summary(smile__svm_model_6C.2_pred)
## spontaneous deliberate  
##          41          24
smile__svm_model_6C.2_confM <- confusionMatrix(
  smile__svm_model_6C.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_6C.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          21          20
##   deliberate           12          12
##                                          
##                Accuracy : 0.5077         
##                  95% CI : (0.3807, 0.634)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.5495         
##                                          
##                   Kappa : 0.0114         
##                                          
##  Mcnemar's Test P-Value : 0.2159         
##                                          
##             Sensitivity : 0.6364         
##             Specificity : 0.3750         
##          Pos Pred Value : 0.5122         
##          Neg Pred Value : 0.5000         
##              Prevalence : 0.5077         
##          Detection Rate : 0.3231         
##    Detection Prevalence : 0.6308         
##       Balanced Accuracy : 0.5057         
##                                          
##        'Positive' Class : spontaneous    
## 
# model 6D onset + eye
set.seed(1973)
smile__svm_model_6D <- train(smile_type ~ onset_mean + eye_mean,
  method = "svmLinear", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_6D$results
##   C  Accuracy      Kappa AccuracySD  KappaSD
## 1 1 0.5433155 0.08600491  0.1022142 0.206062
summary(smile__svm_model_6D$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
kernlab::plot(smile__svm_model_6D$finalModel)

smile__svm_model_6D_pred <- predict(smile__svm_model_6D, tst_smile)
summary(smile__svm_model_6D_pred)
## spontaneous deliberate  
##          60          82
smile__svm_model_6D_confM <- confusionMatrix(
  smile__svm_model_6D_pred,
  tst_smile$smile_type
)
smile__svm_model_6D_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          33          27
##   deliberate           37          45
##                                           
##                Accuracy : 0.5493          
##                  95% CI : (0.4636, 0.6328)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.1780          
##                                           
##                   Kappa : 0.0966          
##                                           
##  Mcnemar's Test P-Value : 0.2606          
##                                           
##             Sensitivity : 0.4714          
##             Specificity : 0.6250          
##          Pos Pred Value : 0.5500          
##          Neg Pred Value : 0.5488          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2324          
##    Detection Prevalence : 0.4225          
##       Balanced Accuracy : 0.5482          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_6D.1_pred <- predict(smile__svm_model_6D, tst_smile_boys)
summary(smile__svm_model_6D.1_pred)
## spontaneous deliberate  
##          27          50
smile__svm_model_6D.1_confM <- confusionMatrix(
  smile__svm_model_6D.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_6D.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          14          13
##   deliberate           23          27
##                                           
##                Accuracy : 0.5325          
##                  95% CI : (0.4152, 0.6471)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.4552          
##                                           
##                   Kappa : 0.0539          
##                                           
##  Mcnemar's Test P-Value : 0.1336          
##                                           
##             Sensitivity : 0.3784          
##             Specificity : 0.6750          
##          Pos Pred Value : 0.5185          
##          Neg Pred Value : 0.5400          
##              Prevalence : 0.4805          
##          Detection Rate : 0.1818          
##    Detection Prevalence : 0.3506          
##       Balanced Accuracy : 0.5267          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_6D.2_pred <- predict(smile__svm_model_6D, tst_smile_girls)
summary(smile__svm_model_6D.2_pred)
## spontaneous deliberate  
##          33          32
smile__svm_model_6D.2_confM <- confusionMatrix(
  smile__svm_model_6D.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_6D.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          19          14
##   deliberate           14          18
##                                           
##                Accuracy : 0.5692          
##                  95% CI : (0.4404, 0.6915)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.1927          
##                                           
##                   Kappa : 0.1383          
##                                           
##  Mcnemar's Test P-Value : 1.0000          
##                                           
##             Sensitivity : 0.5758          
##             Specificity : 0.5625          
##          Pos Pred Value : 0.5758          
##          Neg Pred Value : 0.5625          
##              Prevalence : 0.5077          
##          Detection Rate : 0.2923          
##    Detection Prevalence : 0.5077          
##       Balanced Accuracy : 0.5691          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 6E onset + lip
set.seed(1973)
smile__svm_model_6E <- train(smile_type ~ onset_mean + lip_mean,
  method = "svmLinear", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_6E$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.6483344 0.2962302 0.06798322 0.1368051
summary(smile__svm_model_6E$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
kernlab::plot(smile__svm_model_6E$finalModel)

smile__svm_model_6E_pred <- predict(smile__svm_model_6E, tst_smile)
summary(smile__svm_model_6E_pred)
## spontaneous deliberate  
##          77          65
smile__svm_model_6E_confM <- confusionMatrix(
  smile__svm_model_6E_pred,
  tst_smile$smile_type
)
print(smile__svm_model_6E_confM)
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          43          34
##   deliberate           27          38
##                                           
##                Accuracy : 0.5704          
##                  95% CI : (0.4847, 0.6531)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.07664         
##                                           
##                   Kappa : 0.1419          
##                                           
##  Mcnemar's Test P-Value : 0.44236         
##                                           
##             Sensitivity : 0.6143          
##             Specificity : 0.5278          
##          Pos Pred Value : 0.5584          
##          Neg Pred Value : 0.5846          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3028          
##    Detection Prevalence : 0.5423          
##       Balanced Accuracy : 0.5710          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_6E.1_pred <- predict(smile__svm_model_6E, tst_smile_boys)
summary(smile__svm_model_6E.1_pred)
## spontaneous deliberate  
##          36          41
smile__svm_model_6E.1_confM <- confusionMatrix(
  smile__svm_model_6E.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_6E.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          21          15
##   deliberate           16          25
##                                           
##                Accuracy : 0.5974          
##                  95% CI : (0.4794, 0.7077)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.1045          
##                                           
##                   Kappa : 0.1928          
##                                           
##  Mcnemar's Test P-Value : 1.0000          
##                                           
##             Sensitivity : 0.5676          
##             Specificity : 0.6250          
##          Pos Pred Value : 0.5833          
##          Neg Pred Value : 0.6098          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2727          
##    Detection Prevalence : 0.4675          
##       Balanced Accuracy : 0.5963          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_6E.2_pred <- predict(smile__svm_model_6E, tst_smile_girls)
summary(smile__svm_model_6E.2_pred)
## spontaneous deliberate  
##          41          24
smile__svm_model_6E.2_confM <- confusionMatrix(
  smile__svm_model_6E.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_6E.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          22          19
##   deliberate           11          13
##                                          
##                Accuracy : 0.5385         
##                  95% CI : (0.4103, 0.663)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.3553         
##                                          
##                   Kappa : 0.0732         
##                                          
##  Mcnemar's Test P-Value : 0.2012         
##                                          
##             Sensitivity : 0.6667         
##             Specificity : 0.4062         
##          Pos Pred Value : 0.5366         
##          Neg Pred Value : 0.5417         
##              Prevalence : 0.5077         
##          Detection Rate : 0.3385         
##    Detection Prevalence : 0.6308         
##       Balanced Accuracy : 0.5365         
##                                          
##        'Positive' Class : spontaneous    
## 
# model 6F apex + movements
set.seed(1973)
smile__svm_model_6F <- train(smile_type ~ apex_mean + eye_mean + lip_mean,
  method = "svmLinear", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_6F$results
##   C  Accuracy      Kappa AccuracySD KappaSD
## 1 1 0.5406473 0.08103459 0.09625901 0.19191
summary(smile__svm_model_6F$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_6F_pred <- predict(smile__svm_model_6F, tst_smile)
summary(smile__svm_model_6F_pred)
## spontaneous deliberate  
##          70          72
smile__svm_model_6F_confM <- confusionMatrix(
  smile__svm_model_6F_pred,
  tst_smile$smile_type
)
smile__svm_model_6F_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          41          29
##   deliberate           29          43
##                                          
##                Accuracy : 0.5915         
##                  95% CI : (0.506, 0.6732)
##     No Information Rate : 0.507          
##     P-Value [Acc > NIR] : 0.02653        
##                                          
##                   Kappa : 0.1829         
##                                          
##  Mcnemar's Test P-Value : 1.00000        
##                                          
##             Sensitivity : 0.5857         
##             Specificity : 0.5972         
##          Pos Pred Value : 0.5857         
##          Neg Pred Value : 0.5972         
##              Prevalence : 0.4930         
##          Detection Rate : 0.2887         
##    Detection Prevalence : 0.4930         
##       Balanced Accuracy : 0.5915         
##                                          
##        'Positive' Class : spontaneous    
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_6F.1_pred <- predict(smile__svm_model_6F, tst_smile_boys)
summary(smile__svm_model_6F.1_pred)
## spontaneous deliberate  
##          38          39
smile__svm_model_6F.1_confM <- confusionMatrix(
  smile__svm_model_6F.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_6F.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          21          17
##   deliberate           16          23
##                                           
##                Accuracy : 0.5714          
##                  95% CI : (0.4535, 0.6837)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.2126          
##                                           
##                   Kappa : 0.1424          
##                                           
##  Mcnemar's Test P-Value : 1.0000          
##                                           
##             Sensitivity : 0.5676          
##             Specificity : 0.5750          
##          Pos Pred Value : 0.5526          
##          Neg Pred Value : 0.5897          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2727          
##    Detection Prevalence : 0.4935          
##       Balanced Accuracy : 0.5713          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_6F.2_pred <- predict(smile__svm_model_6F, tst_smile_girls)
summary(smile__svm_model_6F.2_pred)
## spontaneous deliberate  
##          32          33
smile__svm_model_6F.2_confM <- confusionMatrix(
  smile__svm_model_6F.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_6F.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          20          12
##   deliberate           13          20
##                                           
##                Accuracy : 0.6154          
##                  95% CI : (0.4864, 0.7335)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.05294         
##                                           
##                   Kappa : 0.231           
##                                           
##  Mcnemar's Test P-Value : 1.00000         
##                                           
##             Sensitivity : 0.6061          
##             Specificity : 0.6250          
##          Pos Pred Value : 0.6250          
##          Neg Pred Value : 0.6061          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3077          
##    Detection Prevalence : 0.4923          
##       Balanced Accuracy : 0.6155          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 6G apex + eye
set.seed(1973)
smile__svm_model_6G <- train(smile_type ~ apex_mean + eye_mean,
  method = "svmLinear", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_6G$results
##   C  Accuracy      Kappa AccuracySD   KappaSD
## 1 1 0.5381684 0.07448867 0.06085767 0.1208593
summary(smile__svm_model_6G$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
plot(smile__svm_model_6G$finalModel)

smile__svm_model_6G_pred <- predict(smile__svm_model_6G, tst_smile)
summary(smile__svm_model_6G_pred)
## spontaneous deliberate  
##          51          91
smile__svm_model_6G_confM <- confusionMatrix(
  smile__svm_model_6G_pred,
  tst_smile$smile_type
)
smile__svm_model_6G_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          26          25
##   deliberate           44          47
##                                           
##                Accuracy : 0.5141          
##                  95% CI : (0.4288, 0.5987)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.46673         
##                                           
##                   Kappa : 0.0243          
##                                           
##  Mcnemar's Test P-Value : 0.03024         
##                                           
##             Sensitivity : 0.3714          
##             Specificity : 0.6528          
##          Pos Pred Value : 0.5098          
##          Neg Pred Value : 0.5165          
##              Prevalence : 0.4930          
##          Detection Rate : 0.1831          
##    Detection Prevalence : 0.3592          
##       Balanced Accuracy : 0.5121          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_6G.1_pred <- predict(smile__svm_model_6G, tst_smile_boys)
summary(smile__svm_model_6G.1_pred)
## spontaneous deliberate  
##          29          48
smile__svm_model_6G.1_confM <- confusionMatrix(
  smile__svm_model_6G.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_6G.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          16          13
##   deliberate           21          27
##                                           
##                Accuracy : 0.5584          
##                  95% CI : (0.4407, 0.6716)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.2847          
##                                           
##                   Kappa : 0.1083          
##                                           
##  Mcnemar's Test P-Value : 0.2299          
##                                           
##             Sensitivity : 0.4324          
##             Specificity : 0.6750          
##          Pos Pred Value : 0.5517          
##          Neg Pred Value : 0.5625          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2078          
##    Detection Prevalence : 0.3766          
##       Balanced Accuracy : 0.5537          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_6G.2_pred <- predict(smile__svm_model_6G, tst_smile_girls)
summary(smile__svm_model_6G.2_pred)
## spontaneous deliberate  
##          22          43
smile__svm_model_6G.2_confM <- confusionMatrix(
  smile__svm_model_6G.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_6G.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          10          12
##   deliberate           23          20
##                                          
##                Accuracy : 0.4615         
##                  95% CI : (0.337, 0.5897)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.80736        
##                                          
##                   Kappa : -0.0716        
##                                          
##  Mcnemar's Test P-Value : 0.09097        
##                                          
##             Sensitivity : 0.3030         
##             Specificity : 0.6250         
##          Pos Pred Value : 0.4545         
##          Neg Pred Value : 0.4651         
##              Prevalence : 0.5077         
##          Detection Rate : 0.1538         
##    Detection Prevalence : 0.3385         
##       Balanced Accuracy : 0.4640         
##                                          
##        'Positive' Class : spontaneous    
## 
# model 6H apex + lip
set.seed(1973)
smile__svm_model_6H <- train(smile_type ~ apex_mean + lip_mean,
  method = "svmLinear", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_6H$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.5642714 0.1292836  0.0968237 0.1914572
summary(smile__svm_model_6H$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
kernlab::plot(smile__svm_model_6H$finalModel)

smile__svm_model_6H_pred <- predict(smile__svm_model_6H, tst_smile)
summary(smile__svm_model_6H_pred)
## spontaneous deliberate  
##          79          63
smile__svm_model_6H_confM <- confusionMatrix(
  smile__svm_model_6H_pred,
  tst_smile$smile_type
)
smile__svm_model_6H_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          46          33
##   deliberate           24          39
##                                           
##                Accuracy : 0.5986          
##                  95% CI : (0.5131, 0.6799)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.0177          
##                                           
##                   Kappa : 0.1985          
##                                           
##  Mcnemar's Test P-Value : 0.2893          
##                                           
##             Sensitivity : 0.6571          
##             Specificity : 0.5417          
##          Pos Pred Value : 0.5823          
##          Neg Pred Value : 0.6190          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3239          
##    Detection Prevalence : 0.5563          
##       Balanced Accuracy : 0.5994          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_6H.1_pred <- predict(smile__svm_model_6H, tst_smile_boys)
summary(smile__svm_model_6H.1_pred)
## spontaneous deliberate  
##          40          37
smile__svm_model_6H.1_confM <- confusionMatrix(
  smile__svm_model_6H.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_6H.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          23          17
##   deliberate           14          23
##                                           
##                Accuracy : 0.5974          
##                  95% CI : (0.4794, 0.7077)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.1045          
##                                           
##                   Kappa : 0.196           
##                                           
##  Mcnemar's Test P-Value : 0.7194          
##                                           
##             Sensitivity : 0.6216          
##             Specificity : 0.5750          
##          Pos Pred Value : 0.5750          
##          Neg Pred Value : 0.6216          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2987          
##    Detection Prevalence : 0.5195          
##       Balanced Accuracy : 0.5983          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_6H.2_pred <- predict(smile__svm_model_6H, tst_smile_girls)
summary(smile__svm_model_6H.2_pred)
## spontaneous deliberate  
##          39          26
smile__svm_model_6H.2_confM <- confusionMatrix(
  smile__svm_model_6H.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_6H.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          23          16
##   deliberate           10          16
##                                          
##                Accuracy : 0.6            
##                  95% CI : (0.471, 0.7196)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.08588        
##                                          
##                   Kappa : 0.1975         
##                                          
##  Mcnemar's Test P-Value : 0.32680        
##                                          
##             Sensitivity : 0.6970         
##             Specificity : 0.5000         
##          Pos Pred Value : 0.5897         
##          Neg Pred Value : 0.6154         
##              Prevalence : 0.5077         
##          Detection Rate : 0.3538         
##    Detection Prevalence : 0.6000         
##       Balanced Accuracy : 0.5985         
##                                          
##        'Positive' Class : spontaneous    
## 
# model 6I offset and movement
set.seed(1973)
smile__svm_model_6I <- train(smile_type ~ offset_mean + eye_mean + lip_mean,
  method = "svmLinear", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_6I$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.6662377 0.3343434 0.07243843 0.1434402
summary(smile__svm_model_6I$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_6I_pred <- predict(smile__svm_model_6I, tst_smile)
summary(smile__svm_model_6I_pred)
## spontaneous deliberate  
##          82          60
smile__svm_model_6I_confM <- confusionMatrix(
  smile__svm_model_6I_pred,
  tst_smile$smile_type
)
smile__svm_model_6I_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          51          31
##   deliberate           19          41
##                                           
##                Accuracy : 0.6479          
##                  95% CI : (0.5634, 0.7261)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.0004898       
##                                           
##                   Kappa : 0.2973          
##                                           
##  Mcnemar's Test P-Value : 0.1197949       
##                                           
##             Sensitivity : 0.7286          
##             Specificity : 0.5694          
##          Pos Pred Value : 0.6220          
##          Neg Pred Value : 0.6833          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3592          
##    Detection Prevalence : 0.5775          
##       Balanced Accuracy : 0.6490          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_6I.1_pred <- predict(smile__svm_model_6I, tst_smile_boys)
summary(smile__svm_model_6I.1_pred)
## spontaneous deliberate  
##          38          39
smile__svm_model_6I.1_confM <- confusionMatrix(
  smile__svm_model_6I.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_6I.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          25          13
##   deliberate           12          27
##                                          
##                Accuracy : 0.6753         
##                  95% CI : (0.559, 0.7777)
##     No Information Rate : 0.5195         
##     P-Value [Acc > NIR] : 0.00403        
##                                          
##                   Kappa : 0.3503         
##                                          
##  Mcnemar's Test P-Value : 1.00000        
##                                          
##             Sensitivity : 0.6757         
##             Specificity : 0.6750         
##          Pos Pred Value : 0.6579         
##          Neg Pred Value : 0.6923         
##              Prevalence : 0.4805         
##          Detection Rate : 0.3247         
##    Detection Prevalence : 0.4935         
##       Balanced Accuracy : 0.6753         
##                                          
##        'Positive' Class : spontaneous    
## 
set.seed(1973)
smile__svm_model_6I.2_pred <- predict(smile__svm_model_6I, tst_smile_girls)
summary(smile__svm_model_6I.2_pred)
## spontaneous deliberate  
##          44          21
smile__svm_model_6I.2_confM <- confusionMatrix(
  smile__svm_model_6I.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_6I.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          26          18
##   deliberate            7          14
##                                           
##                Accuracy : 0.6154          
##                  95% CI : (0.4864, 0.7335)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.05294         
##                                           
##                   Kappa : 0.2266          
##                                           
##  Mcnemar's Test P-Value : 0.04550         
##                                           
##             Sensitivity : 0.7879          
##             Specificity : 0.4375          
##          Pos Pred Value : 0.5909          
##          Neg Pred Value : 0.6667          
##              Prevalence : 0.5077          
##          Detection Rate : 0.4000          
##    Detection Prevalence : 0.6769          
##       Balanced Accuracy : 0.6127          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 6J offset + eye
set.seed(1973)
smile__svm_model_6J <- train(smile_type ~ offset_mean + eye_mean,
  method = "svmLinear", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_6J$results
##   C Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.552217 0.1031459  0.1055909 0.2110006
summary(smile__svm_model_6J$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
kernlab::plot(smile__svm_model_6J$finalModel)

smile__svm_model_6J_pred <- predict(smile__svm_model_6J, tst_smile)
summary(smile__svm_model_6J_pred)
## spontaneous deliberate  
##          62          80
smile__svm_model_6J_confM <- confusionMatrix(
  smile__svm_model_6J_pred,
  tst_smile$smile_type
)
smile__svm_model_6J_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          40          22
##   deliberate           30          50
##                                          
##                Accuracy : 0.6338         
##                  95% CI : (0.5489, 0.713)
##     No Information Rate : 0.507          
##     P-Value [Acc > NIR] : 0.001568       
##                                          
##                   Kappa : 0.2663         
##                                          
##  Mcnemar's Test P-Value : 0.331685       
##                                          
##             Sensitivity : 0.5714         
##             Specificity : 0.6944         
##          Pos Pred Value : 0.6452         
##          Neg Pred Value : 0.6250         
##              Prevalence : 0.4930         
##          Detection Rate : 0.2817         
##    Detection Prevalence : 0.4366         
##       Balanced Accuracy : 0.6329         
##                                          
##        'Positive' Class : spontaneous    
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_6J.1_pred <- predict(smile__svm_model_6J, tst_smile_boys)
summary(smile__svm_model_6J.1_pred)
## spontaneous deliberate  
##          30          47
smile__svm_model_6J.1_confM <- confusionMatrix(
  smile__svm_model_6J.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_6J.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          18          12
##   deliberate           19          28
##                                           
##                Accuracy : 0.5974          
##                  95% CI : (0.4794, 0.7077)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.1045          
##                                           
##                   Kappa : 0.1878          
##                                           
##  Mcnemar's Test P-Value : 0.2812          
##                                           
##             Sensitivity : 0.4865          
##             Specificity : 0.7000          
##          Pos Pred Value : 0.6000          
##          Neg Pred Value : 0.5957          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2338          
##    Detection Prevalence : 0.3896          
##       Balanced Accuracy : 0.5932          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_6J.2_pred <- predict(smile__svm_model_6J, tst_smile_girls)
summary(smile__svm_model_6J.2_pred)
## spontaneous deliberate  
##          32          33
smile__svm_model_6J.2_confM <- confusionMatrix(
  smile__svm_model_6J.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_6J.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          22          10
##   deliberate           11          22
##                                           
##                Accuracy : 0.6769          
##                  95% CI : (0.5495, 0.7877)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.004282        
##                                           
##                   Kappa : 0.354           
##                                           
##  Mcnemar's Test P-Value : 1.000000        
##                                           
##             Sensitivity : 0.6667          
##             Specificity : 0.6875          
##          Pos Pred Value : 0.6875          
##          Neg Pred Value : 0.6667          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3385          
##    Detection Prevalence : 0.4923          
##       Balanced Accuracy : 0.6771          
##                                           
##        'Positive' Class : spontaneous     
## 
# model 6K offset + lip
set.seed(1973)
smile__svm_model_6K <- train(smile_type ~ offset_mean + lip_mean,
  method = "svmLinear", data = trn_smile,
  trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_6K
## Support Vector Machines with Linear Kernel 
## 
## 333 samples
##   2 predictor
##   2 classes: 'spontaneous', 'deliberate ' 
## 
## No pre-processing
## Resampling: Cross-Validated (10 fold) 
## Summary of sample sizes: 300, 300, 300, 299, 299, 300, ... 
## Resampling results:
## 
##   Accuracy   Kappa    
##   0.6787322  0.3589939
## 
## Tuning parameter 'C' was held constant at a value of 1
smile__svm_model_6K$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.6787322 0.3589939 0.07408875 0.1473768
summary(smile__svm_model_6K$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
kernlab::plot(smile__svm_model_6K$finalModel)

smile__svm_model_6K$bestTune
##   C
## 1 1
smile__svm_model_6K_pred <- predict(smile__svm_model_6K, tst_smile)
summary(smile__svm_model_6K_pred)
## spontaneous deliberate  
##          83          59
smile__svm_model_6K_confM <- confusionMatrix(
  smile__svm_model_6K_pred,
  tst_smile$smile_type
)
smile__svm_model_6K_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          53          30
##   deliberate           17          42
##                                           
##                Accuracy : 0.669           
##                  95% CI : (0.5852, 0.7456)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 6.871e-05       
##                                           
##                   Kappa : 0.3396          
##                                           
##  Mcnemar's Test P-Value : 0.08005         
##                                           
##             Sensitivity : 0.7571          
##             Specificity : 0.5833          
##          Pos Pred Value : 0.6386          
##          Neg Pred Value : 0.7119          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3732          
##    Detection Prevalence : 0.5845          
##       Balanced Accuracy : 0.6702          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_6K.1_pred <- predict(smile__svm_model_6K, tst_smile_boys)
summary(smile__svm_model_6K.1_pred)
## spontaneous deliberate  
##          42          35
smile__svm_model_6K.1_confM <- confusionMatrix(
  smile__svm_model_6K.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_6K.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          27          15
##   deliberate           10          25
##                                          
##                Accuracy : 0.6753         
##                  95% CI : (0.559, 0.7777)
##     No Information Rate : 0.5195         
##     P-Value [Acc > NIR] : 0.00403        
##                                          
##                   Kappa : 0.3529         
##                                          
##  Mcnemar's Test P-Value : 0.42371        
##                                          
##             Sensitivity : 0.7297         
##             Specificity : 0.6250         
##          Pos Pred Value : 0.6429         
##          Neg Pred Value : 0.7143         
##              Prevalence : 0.4805         
##          Detection Rate : 0.3506         
##    Detection Prevalence : 0.5455         
##       Balanced Accuracy : 0.6774         
##                                          
##        'Positive' Class : spontaneous    
## 
set.seed(1973)
smile__svm_model_6K.2_pred <- predict(smile__svm_model_6K, tst_smile_girls)
summary(smile__svm_model_6K.2_pred)
## spontaneous deliberate  
##          41          24
smile__svm_model_6K.2_confM <- confusionMatrix(
  smile__svm_model_6K.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_6K.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          26          15
##   deliberate            7          17
##                                           
##                Accuracy : 0.6615          
##                  95% CI : (0.5335, 0.7743)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.008794        
##                                           
##                   Kappa : 0.3203          
##                                           
##  Mcnemar's Test P-Value : 0.135593        
##                                           
##             Sensitivity : 0.7879          
##             Specificity : 0.5312          
##          Pos Pred Value : 0.6341          
##          Neg Pred Value : 0.7083          
##              Prevalence : 0.5077          
##          Detection Rate : 0.4000          
##    Detection Prevalence : 0.6308          
##       Balanced Accuracy : 0.6596          
##                                           
##        'Positive' Class : spontaneous     
## 
# dynamics and AU's
set.seed(1973)
smile__svm_model_7 <- train(smile_type ~ AU01_r_mean + AU02_r_mean +
  AU04_r_mean + AU05_r_mean + AU06_r_mean +
  AU07_r_mean + AU09_r_mean + AU10_r_mean +
  AU12_r_mean + AU14_r_mean + AU15_r_mean +
  AU17_r_mean + AU20_r_mean + AU23_r_mean +
  AU25_r_mean + AU26_r_mean + AU45_r_mean +
  onset_mean + apex_mean + offset_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_7$results
##   C  Accuracy     Kappa AccuracySD  KappaSD
## 1 1 0.7498552 0.4990742  0.1107154 0.221964
summary(smile__svm_model_7$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_7_pred <- predict(smile__svm_model_7, tst_smile)
summary(smile__svm_model_7_pred)
## spontaneous deliberate  
##          68          74
smile__svm_model_7_confM <- confusionMatrix(
  smile__svm_model_7_pred,
  tst_smile$smile_type
)
smile__svm_model_7_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          46          22
##   deliberate           24          50
##                                           
##                Accuracy : 0.6761          
##                  95% CI : (0.5925, 0.7521)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 3.363e-05       
##                                           
##                   Kappa : 0.3517          
##                                           
##  Mcnemar's Test P-Value : 0.8828          
##                                           
##             Sensitivity : 0.6571          
##             Specificity : 0.6944          
##          Pos Pred Value : 0.6765          
##          Neg Pred Value : 0.6757          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3239          
##    Detection Prevalence : 0.4789          
##       Balanced Accuracy : 0.6758          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_7.1_pred <- predict(smile__svm_model_7, tst_smile_boys)
summary(smile__svm_model_7.1_pred)
## spontaneous deliberate  
##          35          42
smile__svm_model_7.1_confM <- confusionMatrix(
  smile__svm_model_7.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_7.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          24          11
##   deliberate           13          29
##                                           
##                Accuracy : 0.6883          
##                  95% CI : (0.5726, 0.7891)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.001955        
##                                           
##                   Kappa : 0.3744          
##                                           
##  Mcnemar's Test P-Value : 0.838256        
##                                           
##             Sensitivity : 0.6486          
##             Specificity : 0.7250          
##          Pos Pred Value : 0.6857          
##          Neg Pred Value : 0.6905          
##              Prevalence : 0.4805          
##          Detection Rate : 0.3117          
##    Detection Prevalence : 0.4545          
##       Balanced Accuracy : 0.6868          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_7.2_pred <- predict(smile__svm_model_7, tst_smile_girls)
summary(smile__svm_model_7.2_pred)
## spontaneous deliberate  
##          33          32
smile__svm_model_7.2_confM <- confusionMatrix(
  smile__svm_model_7.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_7.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          22          11
##   deliberate           11          21
##                                           
##                Accuracy : 0.6615          
##                  95% CI : (0.5335, 0.7743)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.008794        
##                                           
##                   Kappa : 0.3229          
##                                           
##  Mcnemar's Test P-Value : 1.000000        
##                                           
##             Sensitivity : 0.6667          
##             Specificity : 0.6562          
##          Pos Pred Value : 0.6667          
##          Neg Pred Value : 0.6562          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3385          
##    Detection Prevalence : 0.5077          
##       Balanced Accuracy : 0.6615          
##                                           
##        'Positive' Class : spontaneous     
## 
# 7A AU's and onset

set.seed(1973)
smile__svm_model_7A <- train(smile_type ~ AU01_r_mean + AU02_r_mean +
  AU04_r_mean + AU05_r_mean + AU06_r_mean +
  AU07_r_mean + AU09_r_mean + AU10_r_mean +
  AU12_r_mean + AU14_r_mean + AU15_r_mean +
  AU17_r_mean + AU20_r_mean + AU23_r_mean +
  AU25_r_mean + AU26_r_mean + AU45_r_mean +
  onset_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_7A$results
##   C  Accuracy     Kappa AccuracySD  KappaSD
## 1 1 0.6871992 0.3758363  0.1064631 0.210235
summary(smile__svm_model_7A$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_7A_pred <- predict(smile__svm_model_7A, tst_smile)
summary(smile__svm_model_7A_pred)
## spontaneous deliberate  
##          61          81
smile__svm_model_7A_confM <- confusionMatrix(
  smile__svm_model_7A_pred,
  tst_smile$smile_type
)
smile__svm_model_7A_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          36          25
##   deliberate           34          47
##                                           
##                Accuracy : 0.5845          
##                  95% CI : (0.4989, 0.6665)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.03874         
##                                           
##                   Kappa : 0.1674          
##                                           
##  Mcnemar's Test P-Value : 0.29764         
##                                           
##             Sensitivity : 0.5143          
##             Specificity : 0.6528          
##          Pos Pred Value : 0.5902          
##          Neg Pred Value : 0.5802          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2535          
##    Detection Prevalence : 0.4296          
##       Balanced Accuracy : 0.5835          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_7A.1_pred <- predict(smile__svm_model_7A, tst_smile_boys)
summary(smile__svm_model_7A.1_pred)
## spontaneous deliberate  
##          33          44
smile__svm_model_7A.1_confM <- confusionMatrix(
  smile__svm_model_7A.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_7A.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          20          13
##   deliberate           17          27
##                                           
##                Accuracy : 0.6104          
##                  95% CI : (0.4925, 0.7195)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.06859         
##                                           
##                   Kappa : 0.2164          
##                                           
##  Mcnemar's Test P-Value : 0.58388         
##                                           
##             Sensitivity : 0.5405          
##             Specificity : 0.6750          
##          Pos Pred Value : 0.6061          
##          Neg Pred Value : 0.6136          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2597          
##    Detection Prevalence : 0.4286          
##       Balanced Accuracy : 0.6078          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_7A.2_pred <- predict(smile__svm_model_7A, tst_smile_girls)
summary(smile__svm_model_7A.2_pred)
## spontaneous deliberate  
##          28          37
smile__svm_model_7A.2_confM <- confusionMatrix(
  smile__svm_model_7A.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_7A.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          16          12
##   deliberate           17          20
##                                           
##                Accuracy : 0.5538          
##                  95% CI : (0.4253, 0.6773)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.2678          
##                                           
##                   Kappa : 0.1096          
##                                           
##  Mcnemar's Test P-Value : 0.4576          
##                                           
##             Sensitivity : 0.4848          
##             Specificity : 0.6250          
##          Pos Pred Value : 0.5714          
##          Neg Pred Value : 0.5405          
##              Prevalence : 0.5077          
##          Detection Rate : 0.2462          
##    Detection Prevalence : 0.4308          
##       Balanced Accuracy : 0.5549          
##                                           
##        'Positive' Class : spontaneous     
## 
# 7B AU's and apex

set.seed(1973)
smile__svm_model_7B <- train(smile_type ~ AU01_r_mean + AU02_r_mean +
  AU04_r_mean + AU05_r_mean + AU06_r_mean +
  AU07_r_mean + AU09_r_mean + AU10_r_mean +
  AU12_r_mean + AU14_r_mean + AU15_r_mean +
  AU17_r_mean + AU20_r_mean + AU23_r_mean +
  AU25_r_mean + AU26_r_mean + AU45_r_mean +
  apex_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_7B$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.6873886 0.3751691  0.1010571 0.2013494
summary(smile__svm_model_7B$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_7B_pred <- predict(smile__svm_model_7B, tst_smile)
summary(smile__svm_model_7B_pred)
## spontaneous deliberate  
##          60          82
smile__svm_model_7B_confM <- confusionMatrix(
  smile__svm_model_7B_pred,
  tst_smile$smile_type
)
smile__svm_model_7B_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          35          25
##   deliberate           35          47
##                                           
##                Accuracy : 0.5775          
##                  95% CI : (0.4918, 0.6598)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.05517         
##                                           
##                   Kappa : 0.1531          
##                                           
##  Mcnemar's Test P-Value : 0.24528         
##                                           
##             Sensitivity : 0.5000          
##             Specificity : 0.6528          
##          Pos Pred Value : 0.5833          
##          Neg Pred Value : 0.5732          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2465          
##    Detection Prevalence : 0.4225          
##       Balanced Accuracy : 0.5764          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_7B.1_pred <- predict(smile__svm_model_7B, tst_smile_boys)
summary(smile__svm_model_7B.1_pred)
## spontaneous deliberate  
##          32          45
smile__svm_model_7B.1_confM <- confusionMatrix(
  smile__svm_model_7B.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_7B.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          19          13
##   deliberate           18          27
##                                           
##                Accuracy : 0.5974          
##                  95% CI : (0.4794, 0.7077)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.1045          
##                                           
##                   Kappa : 0.1895          
##                                           
##  Mcnemar's Test P-Value : 0.4725          
##                                           
##             Sensitivity : 0.5135          
##             Specificity : 0.6750          
##          Pos Pred Value : 0.5938          
##          Neg Pred Value : 0.6000          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2468          
##    Detection Prevalence : 0.4156          
##       Balanced Accuracy : 0.5943          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_7B.2_pred <- predict(smile__svm_model_7B, tst_smile_girls)
summary(smile__svm_model_7B.2_pred)
## spontaneous deliberate  
##          28          37
smile__svm_model_7B.2_confM <- confusionMatrix(
  smile__svm_model_7B.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_7B.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          16          12
##   deliberate           17          20
##                                           
##                Accuracy : 0.5538          
##                  95% CI : (0.4253, 0.6773)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.2678          
##                                           
##                   Kappa : 0.1096          
##                                           
##  Mcnemar's Test P-Value : 0.4576          
##                                           
##             Sensitivity : 0.4848          
##             Specificity : 0.6250          
##          Pos Pred Value : 0.5714          
##          Neg Pred Value : 0.5405          
##              Prevalence : 0.5077          
##          Detection Rate : 0.2462          
##    Detection Prevalence : 0.4308          
##       Balanced Accuracy : 0.5549          
##                                           
##        'Positive' Class : spontaneous     
## 
# 7C AU's and offset

set.seed(1973)
smile__svm_model_7C <- train(smile_type ~ AU01_r_mean + AU02_r_mean +
  AU04_r_mean + AU05_r_mean + AU06_r_mean +
  AU07_r_mean + AU09_r_mean + AU10_r_mean +
  AU12_r_mean + AU14_r_mean + AU15_r_mean +
  AU17_r_mean + AU20_r_mean + AU23_r_mean +
  AU25_r_mean + AU26_r_mean + AU45_r_mean +
  offset_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_7C$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.6780136 0.3569963 0.09684482 0.1925157
summary(smile__svm_model_7C$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
# visualize the svm using the rattle package
# plot(smile__svm_model_7C$finalModel)

smile__svm_model_7C_pred <- predict(smile__svm_model_7C, tst_smile)
summary(smile__svm_model_7C_pred)
## spontaneous deliberate  
##          64          78
smile__svm_model_7C_confM <- confusionMatrix(
  smile__svm_model_7C_pred,
  tst_smile$smile_type
)
smile__svm_model_7C_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          39          25
##   deliberate           31          47
##                                           
##                Accuracy : 0.6056          
##                  95% CI : (0.5202, 0.6865)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.01151         
##                                           
##                   Kappa : 0.2102          
##                                           
##  Mcnemar's Test P-Value : 0.50404         
##                                           
##             Sensitivity : 0.5571          
##             Specificity : 0.6528          
##          Pos Pred Value : 0.6094          
##          Neg Pred Value : 0.6026          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2746          
##    Detection Prevalence : 0.4507          
##       Balanced Accuracy : 0.6050          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_7C.1_pred <- predict(smile__svm_model_7C, tst_smile_boys)
summary(smile__svm_model_7C.1_pred)
## spontaneous deliberate  
##          34          43
smile__svm_model_7C.1_confM <- confusionMatrix(
  smile__svm_model_7C.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_7C.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          21          13
##   deliberate           16          27
##                                           
##                Accuracy : 0.6234          
##                  95% CI : (0.5056, 0.7313)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.04297         
##                                           
##                   Kappa : 0.2433          
##                                           
##  Mcnemar's Test P-Value : 0.71035         
##                                           
##             Sensitivity : 0.5676          
##             Specificity : 0.6750          
##          Pos Pred Value : 0.6176          
##          Neg Pred Value : 0.6279          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2727          
##    Detection Prevalence : 0.4416          
##       Balanced Accuracy : 0.6213          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_7C.2_pred <- predict(smile__svm_model_7C, tst_smile_girls)
summary(smile__svm_model_7C.2_pred)
## spontaneous deliberate  
##          30          35
smile__svm_model_7C.2_confM <- confusionMatrix(
  smile__svm_model_7C.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_7C.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          18          12
##   deliberate           15          20
##                                           
##                Accuracy : 0.5846          
##                  95% CI : (0.4556, 0.7056)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.1320          
##                                           
##                   Kappa : 0.1702          
##                                           
##  Mcnemar's Test P-Value : 0.7003          
##                                           
##             Sensitivity : 0.5455          
##             Specificity : 0.6250          
##          Pos Pred Value : 0.6000          
##          Neg Pred Value : 0.5714          
##              Prevalence : 0.5077          
##          Detection Rate : 0.2769          
##    Detection Prevalence : 0.4615          
##       Balanced Accuracy : 0.5852          
##                                           
##        'Positive' Class : spontaneous     
## 
# 7D AU's selection and dynamics
set.seed(1973)
smile__svm_model_7D <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + onset_mean + apex_mean +
  offset_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_7D$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.6690842 0.3379967 0.08313076 0.1670725
summary(smile__svm_model_7D$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_7D_pred <- predict(smile__svm_model_7D, tst_smile)
summary(smile__svm_model_7D_pred)
## spontaneous deliberate  
##          60          82
smile__svm_model_7D_confM <- confusionMatrix(
  smile__svm_model_7D_pred,
  tst_smile$smile_type
)
smile__svm_model_7D_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          42          18
##   deliberate           28          54
##                                           
##                Accuracy : 0.6761          
##                  95% CI : (0.5925, 0.7521)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 3.363e-05       
##                                           
##                   Kappa : 0.3507          
##                                           
##  Mcnemar's Test P-Value : 0.1845          
##                                           
##             Sensitivity : 0.6000          
##             Specificity : 0.7500          
##          Pos Pred Value : 0.7000          
##          Neg Pred Value : 0.6585          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2958          
##    Detection Prevalence : 0.4225          
##       Balanced Accuracy : 0.6750          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_7D.1_pred <- predict(smile__svm_model_7D, tst_smile_boys)
summary(smile__svm_model_7D.1_pred)
## spontaneous deliberate  
##          25          52
smile__svm_model_7D.1_confM <- confusionMatrix(
  smile__svm_model_7D.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_7D.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          19           6
##   deliberate           18          34
##                                           
##                Accuracy : 0.6883          
##                  95% CI : (0.5726, 0.7891)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.001955        
##                                           
##                   Kappa : 0.368           
##                                           
##  Mcnemar's Test P-Value : 0.024745        
##                                           
##             Sensitivity : 0.5135          
##             Specificity : 0.8500          
##          Pos Pred Value : 0.7600          
##          Neg Pred Value : 0.6538          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2468          
##    Detection Prevalence : 0.3247          
##       Balanced Accuracy : 0.6818          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_7D.2_pred <- predict(smile__svm_model_7D, tst_smile_girls)
summary(smile__svm_model_7D.2_pred)
## spontaneous deliberate  
##          35          30
smile__svm_model_7D.2_confM <- confusionMatrix(
  smile__svm_model_7D.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_7D.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          23          12
##   deliberate           10          20
##                                           
##                Accuracy : 0.6615          
##                  95% CI : (0.5335, 0.7743)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.008794        
##                                           
##                   Kappa : 0.3223          
##                                           
##  Mcnemar's Test P-Value : 0.831170        
##                                           
##             Sensitivity : 0.6970          
##             Specificity : 0.6250          
##          Pos Pred Value : 0.6571          
##          Neg Pred Value : 0.6667          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3538          
##    Detection Prevalence : 0.5385          
##       Balanced Accuracy : 0.6610          
##                                           
##        'Positive' Class : spontaneous     
## 
# 7E AU's selection and onset

set.seed(1973)
smile__svm_model_7E <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + onset_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_7E$results
##   C Accuracy     Kappa AccuracySD  KappaSD
## 1 1 0.582002 0.1671039 0.06536007 0.131873
summary(smile__svm_model_7E$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_7E_pred <- predict(smile__svm_model_7E, tst_smile)
summary(smile__svm_model_7E_pred)
## spontaneous deliberate  
##          99          43
smile__svm_model_7E_confM <- confusionMatrix(
  smile__svm_model_7E_pred,
  tst_smile$smile_type
)
smile__svm_model_7E_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          51          48
##   deliberate           19          24
##                                           
##                Accuracy : 0.5282          
##                  95% CI : (0.4427, 0.6124)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.3375712       
##                                           
##                   Kappa : 0.0616          
##                                           
##  Mcnemar's Test P-Value : 0.0006245       
##                                           
##             Sensitivity : 0.7286          
##             Specificity : 0.3333          
##          Pos Pred Value : 0.5152          
##          Neg Pred Value : 0.5581          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3592          
##    Detection Prevalence : 0.6972          
##       Balanced Accuracy : 0.5310          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_7E.1_pred <- predict(smile__svm_model_7E, tst_smile_boys)
summary(smile__svm_model_7E.1_pred)
## spontaneous deliberate  
##          51          26
smile__svm_model_7E.1_confM <- confusionMatrix(
  smile__svm_model_7E.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_7E.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          26          25
##   deliberate           11          15
##                                           
##                Accuracy : 0.5325          
##                  95% CI : (0.4152, 0.6471)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.45523         
##                                           
##                   Kappa : 0.0766          
##                                           
##  Mcnemar's Test P-Value : 0.03026         
##                                           
##             Sensitivity : 0.7027          
##             Specificity : 0.3750          
##          Pos Pred Value : 0.5098          
##          Neg Pred Value : 0.5769          
##              Prevalence : 0.4805          
##          Detection Rate : 0.3377          
##    Detection Prevalence : 0.6623          
##       Balanced Accuracy : 0.5389          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_7E.2_pred <- predict(smile__svm_model_7E, tst_smile_girls)
summary(smile__svm_model_7E.2_pred)
## spontaneous deliberate  
##          48          17
smile__svm_model_7E.2_confM <- confusionMatrix(
  smile__svm_model_7E.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_7E.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          25          23
##   deliberate            8           9
##                                           
##                Accuracy : 0.5231          
##                  95% CI : (0.3954, 0.6485)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.45095         
##                                           
##                   Kappa : 0.0391          
##                                           
##  Mcnemar's Test P-Value : 0.01192         
##                                           
##             Sensitivity : 0.7576          
##             Specificity : 0.2812          
##          Pos Pred Value : 0.5208          
##          Neg Pred Value : 0.5294          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3846          
##    Detection Prevalence : 0.7385          
##       Balanced Accuracy : 0.5194          
##                                           
##        'Positive' Class : spontaneous     
## 
# 7B apex AU's selection and apex

set.seed(1973)
smile__svm_model_7F <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + apex_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_7F$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.5768549 0.1536795 0.07359117 0.1488513
summary(smile__svm_model_7F$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_7F_pred <- predict(smile__svm_model_7F, tst_smile)
summary(smile__svm_model_7F_pred)
## spontaneous deliberate  
##          73          69
smile__svm_model_7F_confM <- confusionMatrix(
  smile__svm_model_7F_pred,
  tst_smile$smile_type
)
smile__svm_model_7F_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          38          35
##   deliberate           32          37
##                                           
##                Accuracy : 0.5282          
##                  95% CI : (0.4427, 0.6124)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.3376          
##                                           
##                   Kappa : 0.0567          
##                                           
##  Mcnemar's Test P-Value : 0.8070          
##                                           
##             Sensitivity : 0.5429          
##             Specificity : 0.5139          
##          Pos Pred Value : 0.5205          
##          Neg Pred Value : 0.5362          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2676          
##    Detection Prevalence : 0.5141          
##       Balanced Accuracy : 0.5284          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_7F.1_pred <- predict(smile__svm_model_7F, tst_smile_boys)
summary(smile__svm_model_7F.1_pred)
## spontaneous deliberate  
##          33          44
smile__svm_model_7F.1_confM <- confusionMatrix(
  smile__svm_model_7F.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_7F.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          19          14
##   deliberate           18          26
##                                           
##                Accuracy : 0.5844          
##                  95% CI : (0.4664, 0.6957)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.1523          
##                                           
##                   Kappa : 0.1642          
##                                           
##  Mcnemar's Test P-Value : 0.5959          
##                                           
##             Sensitivity : 0.5135          
##             Specificity : 0.6500          
##          Pos Pred Value : 0.5758          
##          Neg Pred Value : 0.5909          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2468          
##    Detection Prevalence : 0.4286          
##       Balanced Accuracy : 0.5818          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_7F.2_pred <- predict(smile__svm_model_7F, tst_smile_girls)
summary(smile__svm_model_7F.2_pred)
## spontaneous deliberate  
##          40          25
smile__svm_model_7F.2_confM <- confusionMatrix(
  smile__svm_model_7F.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_7F.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          19          21
##   deliberate           14          11
##                                          
##                Accuracy : 0.4615         
##                  95% CI : (0.337, 0.5897)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.8074         
##                                          
##                   Kappa : -0.0808        
##                                          
##  Mcnemar's Test P-Value : 0.3105         
##                                          
##             Sensitivity : 0.5758         
##             Specificity : 0.3438         
##          Pos Pred Value : 0.4750         
##          Neg Pred Value : 0.4400         
##              Prevalence : 0.5077         
##          Detection Rate : 0.2923         
##    Detection Prevalence : 0.6154         
##       Balanced Accuracy : 0.4598         
##                                          
##        'Positive' Class : spontaneous    
## 
# 7G AU's selection and offset

set.seed(1973)
smile__svm_model_7G <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + offset_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_7G$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.5761141 0.1547211 0.06019134 0.1219688
summary(smile__svm_model_7G$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_7G_pred <- predict(smile__svm_model_7G, tst_smile)
summary(smile__svm_model_7G_pred)
## spontaneous deliberate  
##          92          50
smile__svm_model_7G_confM <- confusionMatrix(
  smile__svm_model_7G_pred,
  tst_smile$smile_type
)
smile__svm_model_7G_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          50          42
##   deliberate           20          30
##                                           
##                Accuracy : 0.5634          
##                  95% CI : (0.4777, 0.6464)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.103915        
##                                           
##                   Kappa : 0.1304          
##                                           
##  Mcnemar's Test P-Value : 0.007653        
##                                           
##             Sensitivity : 0.7143          
##             Specificity : 0.4167          
##          Pos Pred Value : 0.5435          
##          Neg Pred Value : 0.6000          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3521          
##    Detection Prevalence : 0.6479          
##       Balanced Accuracy : 0.5655          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_7G.1_pred <- predict(smile__svm_model_7G, tst_smile_boys)
summary(smile__svm_model_7G.1_pred)
## spontaneous deliberate  
##          49          28
smile__svm_model_7G.1_confM <- confusionMatrix(
  smile__svm_model_7G.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_7G.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          25          24
##   deliberate           12          16
##                                           
##                Accuracy : 0.5325          
##                  95% CI : (0.4152, 0.6471)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.45523         
##                                           
##                   Kappa : 0.0748          
##                                           
##  Mcnemar's Test P-Value : 0.06675         
##                                           
##             Sensitivity : 0.6757          
##             Specificity : 0.4000          
##          Pos Pred Value : 0.5102          
##          Neg Pred Value : 0.5714          
##              Prevalence : 0.4805          
##          Detection Rate : 0.3247          
##    Detection Prevalence : 0.6364          
##       Balanced Accuracy : 0.5378          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_7G.2_pred <- predict(smile__svm_model_7G, tst_smile_girls)
summary(smile__svm_model_7G.2_pred)
## spontaneous deliberate  
##          43          22
smile__svm_model_7G.2_confM <- confusionMatrix(
  smile__svm_model_7G.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_7G.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          25          18
##   deliberate            8          14
##                                          
##                Accuracy : 0.6            
##                  95% CI : (0.471, 0.7196)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.08588        
##                                          
##                   Kappa : 0.196          
##                                          
##  Mcnemar's Test P-Value : 0.07756        
##                                          
##             Sensitivity : 0.7576         
##             Specificity : 0.4375         
##          Pos Pred Value : 0.5814         
##          Neg Pred Value : 0.6364         
##              Prevalence : 0.5077         
##          Detection Rate : 0.3846         
##    Detection Prevalence : 0.6615         
##       Balanced Accuracy : 0.5975         
##                                          
##        'Positive' Class : spontaneous    
## 
# 7H selection AU's + temporal features
set.seed(1973)
smile__svm_model_7H <- train(smile_type ~ AU01_r_mean + AU09_r_mean +
  AU10_r_mean + AU25_r_mean + AU45_r_mean +
  onset_mean + apex_mean + offset_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_7H$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.6985851 0.3968121 0.09919617 0.1981549
summary(smile__svm_model_7H$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_7H_pred <- predict(smile__svm_model_7H, tst_smile)
summary(smile__svm_model_7H_pred)
## spontaneous deliberate  
##          59          83
smile__svm_model_7H_confM <- confusionMatrix(
  smile__svm_model_7H_pred,
  tst_smile$smile_type
)
smile__svm_model_7H_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          43          16
##   deliberate           27          56
##                                           
##                Accuracy : 0.6972          
##                  95% CI : (0.6145, 0.7714)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 3.274e-06       
##                                           
##                   Kappa : 0.3929          
##                                           
##  Mcnemar's Test P-Value : 0.1273          
##                                           
##             Sensitivity : 0.6143          
##             Specificity : 0.7778          
##          Pos Pred Value : 0.7288          
##          Neg Pred Value : 0.6747          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3028          
##    Detection Prevalence : 0.4155          
##       Balanced Accuracy : 0.6960          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_7H.1_pred <- predict(smile__svm_model_7H, tst_smile_boys)
summary(smile__svm_model_7H.1_pred)
## spontaneous deliberate  
##          25          52
smile__svm_model_7H.1_confM <- confusionMatrix(
  smile__svm_model_7H.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_7H.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          20           5
##   deliberate           17          35
##                                        
##                Accuracy : 0.7143       
##                  95% CI : (0.6, 0.8115)
##     No Information Rate : 0.5195       
##     P-Value [Acc > NIR] : 0.0003882    
##                                        
##                   Kappa : 0.4207       
##                                        
##  Mcnemar's Test P-Value : 0.0190165    
##                                        
##             Sensitivity : 0.5405       
##             Specificity : 0.8750       
##          Pos Pred Value : 0.8000       
##          Neg Pred Value : 0.6731       
##              Prevalence : 0.4805       
##          Detection Rate : 0.2597       
##    Detection Prevalence : 0.3247       
##       Balanced Accuracy : 0.7078       
##                                        
##        'Positive' Class : spontaneous  
## 
set.seed(1973)
smile__svm_model_7H.2_pred <- predict(smile__svm_model_7H, tst_smile_girls)
summary(smile__svm_model_7H.2_pred)
## spontaneous deliberate  
##          34          31
smile__svm_model_7H.2_confM <- confusionMatrix(
  smile__svm_model_7H.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_7H.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          23          11
##   deliberate           10          21
##                                           
##                Accuracy : 0.6769          
##                  95% CI : (0.5495, 0.7877)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.004282        
##                                           
##                   Kappa : 0.3534          
##                                           
##  Mcnemar's Test P-Value : 1.000000        
##                                           
##             Sensitivity : 0.6970          
##             Specificity : 0.6562          
##          Pos Pred Value : 0.6765          
##          Neg Pred Value : 0.6774          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3538          
##    Detection Prevalence : 0.5231          
##       Balanced Accuracy : 0.6766          
##                                           
##        'Positive' Class : spontaneous     
## 
# 7I

set.seed(1973)
smile__svm_model_7I <- train(smile_type ~ AU01_r_mean + AU09_r_mean +
  AU10_r_mean + AU25_r_mean + AU45_r_mean +
  onset_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_7I$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.6392324 0.2786654 0.06036414 0.1196935
summary(smile__svm_model_7I$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_7I_pred <- predict(smile__svm_model_7I, tst_smile)
summary(smile__svm_model_7I_pred)
## spontaneous deliberate  
##          62          80
smile__svm_model_7I_confM <- confusionMatrix(
  smile__svm_model_7I_pred,
  tst_smile$smile_type
)
smile__svm_model_7I_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          41          21
##   deliberate           29          51
##                                           
##                Accuracy : 0.6479          
##                  95% CI : (0.5634, 0.7261)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.0004898       
##                                           
##                   Kappa : 0.2945          
##                                           
##  Mcnemar's Test P-Value : 0.3221988       
##                                           
##             Sensitivity : 0.5857          
##             Specificity : 0.7083          
##          Pos Pred Value : 0.6613          
##          Neg Pred Value : 0.6375          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2887          
##    Detection Prevalence : 0.4366          
##       Balanced Accuracy : 0.6470          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_7I.1_pred <- predict(smile__svm_model_7I, tst_smile_boys)
summary(smile__svm_model_7I.1_pred)
## spontaneous deliberate  
##          27          50
smile__svm_model_7I.1_confM <- confusionMatrix(
  smile__svm_model_7I.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_7I.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          21           6
##   deliberate           16          34
##                                        
##                Accuracy : 0.7143       
##                  95% CI : (0.6, 0.8115)
##     No Information Rate : 0.5195       
##     P-Value [Acc > NIR] : 0.0003882    
##                                        
##                   Kappa : 0.4218       
##                                        
##  Mcnemar's Test P-Value : 0.0550088    
##                                        
##             Sensitivity : 0.5676       
##             Specificity : 0.8500       
##          Pos Pred Value : 0.7778       
##          Neg Pred Value : 0.6800       
##              Prevalence : 0.4805       
##          Detection Rate : 0.2727       
##    Detection Prevalence : 0.3506       
##       Balanced Accuracy : 0.7088       
##                                        
##        'Positive' Class : spontaneous  
## 
set.seed(1973)
smile__svm_model_7I.2_pred <- predict(smile__svm_model_7I, tst_smile_girls)
summary(smile__svm_model_7I.2_pred)
## spontaneous deliberate  
##          35          30
smile__svm_model_7I.2_confM <- confusionMatrix(
  smile__svm_model_7I.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_7I.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          20          15
##   deliberate           13          17
##                                           
##                Accuracy : 0.5692          
##                  95% CI : (0.4404, 0.6915)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.1927          
##                                           
##                   Kappa : 0.1374          
##                                           
##  Mcnemar's Test P-Value : 0.8501          
##                                           
##             Sensitivity : 0.6061          
##             Specificity : 0.5312          
##          Pos Pred Value : 0.5714          
##          Neg Pred Value : 0.5667          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3077          
##    Detection Prevalence : 0.5385          
##       Balanced Accuracy : 0.5687          
##                                           
##        'Positive' Class : spontaneous     
## 
# 7J

set.seed(1973)
smile__svm_model_7J <- train(smile_type ~ AU01_r_mean + AU09_r_mean +
  AU10_r_mean + AU25_r_mean + AU45_r_mean +
  apex_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_7J$results
##   C  Accuracy    Kappa AccuracySD   KappaSD
## 1 1 0.6424465 0.284497 0.07854931 0.1560307
summary(smile__svm_model_7J$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_7J_pred <- predict(smile__svm_model_7J, tst_smile)
summary(smile__svm_model_7J_pred)
## spontaneous deliberate  
##          65          77
smile__svm_model_7J_confM <- confusionMatrix(
  smile__svm_model_7J_pred,
  tst_smile$smile_type
)
smile__svm_model_7J_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          43          22
##   deliberate           27          50
##                                           
##                Accuracy : 0.6549          
##                  95% CI : (0.5706, 0.7326)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.0002621       
##                                           
##                   Kappa : 0.309           
##                                           
##  Mcnemar's Test P-Value : 0.5677092       
##                                           
##             Sensitivity : 0.6143          
##             Specificity : 0.6944          
##          Pos Pred Value : 0.6615          
##          Neg Pred Value : 0.6494          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3028          
##    Detection Prevalence : 0.4577          
##       Balanced Accuracy : 0.6544          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_7J.1_pred <- predict(smile__svm_model_7J, tst_smile_boys)
summary(smile__svm_model_7J.1_pred)
## spontaneous deliberate  
##          30          47
smile__svm_model_7J.1_confM <- confusionMatrix(
  smile__svm_model_7J.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_7J.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          24           6
##   deliberate           13          34
##                                           
##                Accuracy : 0.7532          
##                  95% CI : (0.6418, 0.8444)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 2.185e-05       
##                                           
##                   Kappa : 0.5022          
##                                           
##  Mcnemar's Test P-Value : 0.1687          
##                                           
##             Sensitivity : 0.6486          
##             Specificity : 0.8500          
##          Pos Pred Value : 0.8000          
##          Neg Pred Value : 0.7234          
##              Prevalence : 0.4805          
##          Detection Rate : 0.3117          
##    Detection Prevalence : 0.3896          
##       Balanced Accuracy : 0.7493          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_7J.2_pred <- predict(smile__svm_model_7J, tst_smile_girls)
summary(smile__svm_model_7J.2_pred)
## spontaneous deliberate  
##          35          30
smile__svm_model_7J.2_confM <- confusionMatrix(
  smile__svm_model_7J.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_7J.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          19          16
##   deliberate           14          16
##                                          
##                Accuracy : 0.5385         
##                  95% CI : (0.4103, 0.663)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.3553         
##                                          
##                   Kappa : 0.0758         
##                                          
##  Mcnemar's Test P-Value : 0.8551         
##                                          
##             Sensitivity : 0.5758         
##             Specificity : 0.5000         
##          Pos Pred Value : 0.5429         
##          Neg Pred Value : 0.5333         
##              Prevalence : 0.5077         
##          Detection Rate : 0.2923         
##    Detection Prevalence : 0.5385         
##       Balanced Accuracy : 0.5379         
##                                          
##        'Positive' Class : spontaneous    
## 
# 7K

set.seed(1973)
smile__svm_model_7K <- train(smile_type ~ AU01_r_mean + AU09_r_mean +
  AU10_r_mean + AU25_r_mean + AU45_r_mean +
  offset_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_7K$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.6302306 0.2607177  0.0555369 0.1093455
summary(smile__svm_model_7K$finalModel)
## Length  Class   Mode 
##      1   ksvm     S4
smile__svm_model_7K_pred <- predict(smile__svm_model_7K, tst_smile)
summary(smile__svm_model_7K_pred)
## spontaneous deliberate  
##          64          78
smile__svm_model_7K_confM <- confusionMatrix(
  smile__svm_model_7K_pred,
  tst_smile$smile_type
)
smile__svm_model_7K_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          42          22
##   deliberate           28          50
##                                           
##                Accuracy : 0.6479          
##                  95% CI : (0.5634, 0.7261)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.0004898       
##                                           
##                   Kappa : 0.2948          
##                                           
##  Mcnemar's Test P-Value : 0.4795001       
##                                           
##             Sensitivity : 0.6000          
##             Specificity : 0.6944          
##          Pos Pred Value : 0.6562          
##          Neg Pred Value : 0.6410          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2958          
##    Detection Prevalence : 0.4507          
##       Balanced Accuracy : 0.6472          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_7K.1_pred <- predict(smile__svm_model_7K, tst_smile_boys)
summary(smile__svm_model_7K.1_pred)
## spontaneous deliberate  
##          30          47
smile__svm_model_7K.1_confM <- confusionMatrix(
  smile__svm_model_7K.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_7K.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          22           8
##   deliberate           15          32
##                                           
##                Accuracy : 0.7013          
##                  95% CI : (0.5862, 0.8003)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.0008966       
##                                           
##                   Kappa : 0.3974          
##                                           
##  Mcnemar's Test P-Value : 0.2109029       
##                                           
##             Sensitivity : 0.5946          
##             Specificity : 0.8000          
##          Pos Pred Value : 0.7333          
##          Neg Pred Value : 0.6809          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2857          
##    Detection Prevalence : 0.3896          
##       Balanced Accuracy : 0.6973          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_7K.2_pred <- predict(smile__svm_model_7K, tst_smile_girls)
summary(smile__svm_model_7K.2_pred)
## spontaneous deliberate  
##          34          31
smile__svm_model_7K.2_confM <- confusionMatrix(
  smile__svm_model_7K.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_7K.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          20          14
##   deliberate           13          18
##                                           
##                Accuracy : 0.5846          
##                  95% CI : (0.4556, 0.7056)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.132           
##                                           
##                   Kappa : 0.1686          
##                                           
##  Mcnemar's Test P-Value : 1.000           
##                                           
##             Sensitivity : 0.6061          
##             Specificity : 0.5625          
##          Pos Pred Value : 0.5882          
##          Neg Pred Value : 0.5806          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3077          
##    Detection Prevalence : 0.5231          
##       Balanced Accuracy : 0.5843          
##                                           
##        'Positive' Class : spontaneous     
## 
# 8 strongest features

# 8A
set.seed(1973)
smile__svm_model_8A <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + onset_mean + apex_mean +
  offset_mean + lip_mean + eye_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_8A$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.6927028 0.3855624 0.08658439 0.1737373
smile__svm_model_8A_pred <- predict(smile__svm_model_8A, tst_smile)
summary(smile__svm_model_8A_pred)
## spontaneous deliberate  
##          68          74
smile__svm_model_8A_confM <- confusionMatrix(
  smile__svm_model_8A_pred,
  tst_smile$smile_type
)
smile__svm_model_8A_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          44          24
##   deliberate           26          48
##                                           
##                Accuracy : 0.6479          
##                  95% CI : (0.5634, 0.7261)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.0004898       
##                                           
##                   Kappa : 0.2954          
##                                           
##  Mcnemar's Test P-Value : 0.8875371       
##                                           
##             Sensitivity : 0.6286          
##             Specificity : 0.6667          
##          Pos Pred Value : 0.6471          
##          Neg Pred Value : 0.6486          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3099          
##    Detection Prevalence : 0.4789          
##       Balanced Accuracy : 0.6476          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_8A.1_pred <- predict(smile__svm_model_8A, tst_smile_boys)
summary(smile__svm_model_8A.1_pred)
## spontaneous deliberate  
##          27          50
smile__svm_model_8A.1_confM <- confusionMatrix(
  smile__svm_model_8A.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_8A.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          19           8
##   deliberate           18          32
##                                           
##                Accuracy : 0.6623          
##                  95% CI : (0.5455, 0.7662)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.007868        
##                                           
##                   Kappa : 0.3167          
##                                           
##  Mcnemar's Test P-Value : 0.077556        
##                                           
##             Sensitivity : 0.5135          
##             Specificity : 0.8000          
##          Pos Pred Value : 0.7037          
##          Neg Pred Value : 0.6400          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2468          
##    Detection Prevalence : 0.3506          
##       Balanced Accuracy : 0.6568          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_8A.2_pred <- predict(smile__svm_model_8A, tst_smile_girls)
summary(smile__svm_model_8A.2_pred)
## spontaneous deliberate  
##          41          24
smile__svm_model_8A.2_confM <- confusionMatrix(
  smile__svm_model_8A.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_8A.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          25          16
##   deliberate            8          16
##                                          
##                Accuracy : 0.6308         
##                  95% CI : (0.502, 0.7472)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.03086        
##                                          
##                   Kappa : 0.2586         
##                                          
##  Mcnemar's Test P-Value : 0.15304        
##                                          
##             Sensitivity : 0.7576         
##             Specificity : 0.5000         
##          Pos Pred Value : 0.6098         
##          Neg Pred Value : 0.6667         
##              Prevalence : 0.5077         
##          Detection Rate : 0.3846         
##    Detection Prevalence : 0.6308         
##       Balanced Accuracy : 0.6288         
##                                          
##        'Positive' Class : spontaneous    
## 
# 8B
set.seed(1973)
smile__svm_model_8B <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + onset_mean + lip_mean + eye_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_8B$results
##   C  Accuracy    Kappa AccuracySD KappaSD
## 1 1 0.6633857 0.327155 0.06435706 0.12877
smile__svm_model_8B_pred <- predict(smile__svm_model_8B, tst_smile)
summary(smile__svm_model_8B_pred)
## spontaneous deliberate  
##          74          68
smile__svm_model_8B_confM <- confusionMatrix(
  smile__svm_model_8B_pred,
  tst_smile$smile_type
)
smile__svm_model_8B_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          44          30
##   deliberate           26          42
##                                           
##                Accuracy : 0.6056          
##                  95% CI : (0.5202, 0.6865)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.01151         
##                                           
##                   Kappa : 0.2117          
##                                           
##  Mcnemar's Test P-Value : 0.68850         
##                                           
##             Sensitivity : 0.6286          
##             Specificity : 0.5833          
##          Pos Pred Value : 0.5946          
##          Neg Pred Value : 0.6176          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3099          
##    Detection Prevalence : 0.5211          
##       Balanced Accuracy : 0.6060          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_8B.1_pred <- predict(smile__svm_model_8B, tst_smile_boys)
summary(smile__svm_model_8B.1_pred)
## spontaneous deliberate  
##          34          43
smile__svm_model_8B.1_confM <- confusionMatrix(
  smile__svm_model_8B.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_8B.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          21          13
##   deliberate           16          27
##                                           
##                Accuracy : 0.6234          
##                  95% CI : (0.5056, 0.7313)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.04297         
##                                           
##                   Kappa : 0.2433          
##                                           
##  Mcnemar's Test P-Value : 0.71035         
##                                           
##             Sensitivity : 0.5676          
##             Specificity : 0.6750          
##          Pos Pred Value : 0.6176          
##          Neg Pred Value : 0.6279          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2727          
##    Detection Prevalence : 0.4416          
##       Balanced Accuracy : 0.6213          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_8B.2_pred <- predict(smile__svm_model_8B, tst_smile_girls)
summary(smile__svm_model_8B.2_pred)
## spontaneous deliberate  
##          40          25
smile__svm_model_8B.2_confM <- confusionMatrix(
  smile__svm_model_8B.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_8B.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          23          17
##   deliberate           10          15
##                                           
##                Accuracy : 0.5846          
##                  95% CI : (0.4556, 0.7056)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.1320          
##                                           
##                   Kappa : 0.1663          
##                                           
##  Mcnemar's Test P-Value : 0.2482          
##                                           
##             Sensitivity : 0.6970          
##             Specificity : 0.4688          
##          Pos Pred Value : 0.5750          
##          Neg Pred Value : 0.6000          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3538          
##    Detection Prevalence : 0.6154          
##       Balanced Accuracy : 0.5829          
##                                           
##        'Positive' Class : spontaneous     
## 
# 8C
set.seed(1973)
smile__svm_model_8C <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + apex_mean + lip_mean + eye_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_8C$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.5919285 0.1842753 0.09834628 0.1972986
smile__svm_model_8C_pred <- predict(smile__svm_model_8C, tst_smile)
summary(smile__svm_model_8C_pred)
## spontaneous deliberate  
##          71          71
smile__svm_model_8C_confM <- confusionMatrix(
  smile__svm_model_8C_pred,
  tst_smile$smile_type
)
smile__svm_model_8C_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          41          30
##   deliberate           29          42
##                                           
##                Accuracy : 0.5845          
##                  95% CI : (0.4989, 0.6665)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.03874         
##                                           
##                   Kappa : 0.169           
##                                           
##  Mcnemar's Test P-Value : 1.00000         
##                                           
##             Sensitivity : 0.5857          
##             Specificity : 0.5833          
##          Pos Pred Value : 0.5775          
##          Neg Pred Value : 0.5915          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2887          
##    Detection Prevalence : 0.5000          
##       Balanced Accuracy : 0.5845          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_8C.1_pred <- predict(smile__svm_model_8C, tst_smile_boys)
summary(smile__svm_model_8C.1_pred)
## spontaneous deliberate  
##          34          43
smile__svm_model_8C.1_confM <- confusionMatrix(
  smile__svm_model_8C.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_8C.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          19          15
##   deliberate           18          25
##                                           
##                Accuracy : 0.5714          
##                  95% CI : (0.4535, 0.6837)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.2126          
##                                           
##                   Kappa : 0.1389          
##                                           
##  Mcnemar's Test P-Value : 0.7277          
##                                           
##             Sensitivity : 0.5135          
##             Specificity : 0.6250          
##          Pos Pred Value : 0.5588          
##          Neg Pred Value : 0.5814          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2468          
##    Detection Prevalence : 0.4416          
##       Balanced Accuracy : 0.5693          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_8C.2_pred <- predict(smile__svm_model_8C, tst_smile_girls)
summary(smile__svm_model_8C.2_pred)
## spontaneous deliberate  
##          37          28
smile__svm_model_8C.2_confM <- confusionMatrix(
  smile__svm_model_8C.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_8C.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          22          15
##   deliberate           11          17
##                                          
##                Accuracy : 0.6            
##                  95% CI : (0.471, 0.7196)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.08588        
##                                          
##                   Kappa : 0.1983         
##                                          
##  Mcnemar's Test P-Value : 0.55630        
##                                          
##             Sensitivity : 0.6667         
##             Specificity : 0.5312         
##          Pos Pred Value : 0.5946         
##          Neg Pred Value : 0.6071         
##              Prevalence : 0.5077         
##          Detection Rate : 0.3385         
##    Detection Prevalence : 0.5692         
##       Balanced Accuracy : 0.5990         
##                                          
##        'Positive' Class : spontaneous    
## 
# 8D
set.seed(1973)
smile__svm_model_8D <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + offset_mean + lip_mean +
  eye_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_8D$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.6632074 0.3276323 0.06838694 0.1362339
smile__svm_model_8D_pred <- predict(smile__svm_model_8D, tst_smile)
summary(smile__svm_model_8D_pred)
## spontaneous deliberate  
##          78          64
smile__svm_model_8D_confM <- confusionMatrix(
  smile__svm_model_8D_pred,
  tst_smile$smile_type
)
smile__svm_model_8D_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          52          26
##   deliberate           18          46
##                                          
##                Accuracy : 0.6901         
##                  95% CI : (0.6072, 0.765)
##     No Information Rate : 0.507          
##     P-Value [Acc > NIR] : 7.345e-06      
##                                          
##                   Kappa : 0.3811         
##                                          
##  Mcnemar's Test P-Value : 0.2913         
##                                          
##             Sensitivity : 0.7429         
##             Specificity : 0.6389         
##          Pos Pred Value : 0.6667         
##          Neg Pred Value : 0.7188         
##              Prevalence : 0.4930         
##          Detection Rate : 0.3662         
##    Detection Prevalence : 0.5493         
##       Balanced Accuracy : 0.6909         
##                                          
##        'Positive' Class : spontaneous    
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_8D.1_pred <- predict(smile__svm_model_8D, tst_smile_boys)
summary(smile__svm_model_8D.1_pred)
## spontaneous deliberate  
##          32          45
smile__svm_model_8D.1_confM <- confusionMatrix(
  smile__svm_model_8D.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_8D.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          23           9
##   deliberate           14          31
##                                           
##                Accuracy : 0.7013          
##                  95% CI : (0.5862, 0.8003)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.0008966       
##                                           
##                   Kappa : 0.3986          
##                                           
##  Mcnemar's Test P-Value : 0.4042485       
##                                           
##             Sensitivity : 0.6216          
##             Specificity : 0.7750          
##          Pos Pred Value : 0.7188          
##          Neg Pred Value : 0.6889          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2987          
##    Detection Prevalence : 0.4156          
##       Balanced Accuracy : 0.6983          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_8D.2_pred <- predict(smile__svm_model_8D, tst_smile_girls)
summary(smile__svm_model_8D.2_pred)
## spontaneous deliberate  
##          46          19
smile__svm_model_8D.2_confM <- confusionMatrix(
  smile__svm_model_8D.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_8D.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          29          17
##   deliberate            4          15
##                                           
##                Accuracy : 0.6769          
##                  95% CI : (0.5495, 0.7877)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.004282        
##                                           
##                   Kappa : 0.3497          
##                                           
##  Mcnemar's Test P-Value : 0.008829        
##                                           
##             Sensitivity : 0.8788          
##             Specificity : 0.4688          
##          Pos Pred Value : 0.6304          
##          Neg Pred Value : 0.7895          
##              Prevalence : 0.5077          
##          Detection Rate : 0.4462          
##    Detection Prevalence : 0.7077          
##       Balanced Accuracy : 0.6738          
##                                           
##        'Positive' Class : spontaneous     
## 
# 8E
set.seed(1973)
smile__svm_model_8E <- train(smile_type ~ AU01_r_mean + AU09_r_mean +
  AU10_r_mean + AU25_r_mean + AU45_r_mean +
  onset_mean + apex_mean + offset_mean + lip_mean +
  eye_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_8E$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.7105336 0.4206647  0.1096118 0.2191265
smile__svm_model_8E_pred <- predict(smile__svm_model_8E, tst_smile)
summary(smile__svm_model_8E_pred)
## spontaneous deliberate  
##          61          81
smile__svm_model_8E_confM <- confusionMatrix(
  smile__svm_model_8E_pred,
  tst_smile$smile_type
)
smile__svm_model_8E_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          47          14
##   deliberate           23          58
##                                           
##                Accuracy : 0.7394          
##                  95% CI : (0.6592, 0.8094)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 1.288e-08       
##                                           
##                   Kappa : 0.4778          
##                                           
##  Mcnemar's Test P-Value : 0.1884          
##                                           
##             Sensitivity : 0.6714          
##             Specificity : 0.8056          
##          Pos Pred Value : 0.7705          
##          Neg Pred Value : 0.7160          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3310          
##    Detection Prevalence : 0.4296          
##       Balanced Accuracy : 0.7385          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_8E.1_pred <- predict(smile__svm_model_8E, tst_smile_boys)
summary(smile__svm_model_8E.1_pred)
## spontaneous deliberate  
##          25          52
smile__svm_model_8E.1_confM <- confusionMatrix(
  smile__svm_model_8E.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_8E.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          21           4
##   deliberate           16          36
##                                           
##                Accuracy : 0.7403          
##                  95% CI : (0.6277, 0.8336)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 6.073e-05       
##                                           
##                   Kappa : 0.4733          
##                                           
##  Mcnemar's Test P-Value : 0.01391         
##                                           
##             Sensitivity : 0.5676          
##             Specificity : 0.9000          
##          Pos Pred Value : 0.8400          
##          Neg Pred Value : 0.6923          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2727          
##    Detection Prevalence : 0.3247          
##       Balanced Accuracy : 0.7338          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_8E.2_pred <- predict(smile__svm_model_8E, tst_smile_girls)
summary(smile__svm_model_8E.2_pred)
## spontaneous deliberate  
##          36          29
smile__svm_model_8E.2_confM <- confusionMatrix(
  smile__svm_model_8E.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_8E.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          26          10
##   deliberate            7          22
##                                           
##                Accuracy : 0.7385          
##                  95% CI : (0.6146, 0.8397)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.0001234       
##                                           
##                   Kappa : 0.4761          
##                                           
##  Mcnemar's Test P-Value : 0.6276258       
##                                           
##             Sensitivity : 0.7879          
##             Specificity : 0.6875          
##          Pos Pred Value : 0.7222          
##          Neg Pred Value : 0.7586          
##              Prevalence : 0.5077          
##          Detection Rate : 0.4000          
##    Detection Prevalence : 0.5538          
##       Balanced Accuracy : 0.7377          
##                                           
##        'Positive' Class : spontaneous     
## 
# 8F
set.seed(1973)
smile__svm_model_8F <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + onset_mean + apex_mean +
  offset_mean + eye_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_8F$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.6602607 0.3204802 0.09509904 0.1915229
smile__svm_model_8F_pred <- predict(smile__svm_model_8F, tst_smile)
summary(smile__svm_model_8F_pred)
## spontaneous deliberate  
##          64          78
smile__svm_model_8F_confM <- confusionMatrix(
  smile__svm_model_8F_pred,
  tst_smile$smile_type
)
smile__svm_model_8F_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          43          21
##   deliberate           27          51
##                                           
##                Accuracy : 0.662           
##                  95% CI : (0.5779, 0.7391)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.0001362       
##                                           
##                   Kappa : 0.323           
##                                           
##  Mcnemar's Test P-Value : 0.4704864       
##                                           
##             Sensitivity : 0.6143          
##             Specificity : 0.7083          
##          Pos Pred Value : 0.6719          
##          Neg Pred Value : 0.6538          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3028          
##    Detection Prevalence : 0.4507          
##       Balanced Accuracy : 0.6613          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_8F.1_pred <- predict(smile__svm_model_8F, tst_smile_boys)
summary(smile__svm_model_8F.1_pred)
## spontaneous deliberate  
##          26          51
smile__svm_model_8F.1_confM <- confusionMatrix(
  smile__svm_model_8F.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_8F.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          19           7
##   deliberate           18          33
##                                          
##                Accuracy : 0.6753         
##                  95% CI : (0.559, 0.7777)
##     No Information Rate : 0.5195         
##     P-Value [Acc > NIR] : 0.00403        
##                                          
##                   Kappa : 0.3423         
##                                          
##  Mcnemar's Test P-Value : 0.04550        
##                                          
##             Sensitivity : 0.5135         
##             Specificity : 0.8250         
##          Pos Pred Value : 0.7308         
##          Neg Pred Value : 0.6471         
##              Prevalence : 0.4805         
##          Detection Rate : 0.2468         
##    Detection Prevalence : 0.3377         
##       Balanced Accuracy : 0.6693         
##                                          
##        'Positive' Class : spontaneous    
## 
set.seed(1973)
smile__svm_model_8F.2_pred <- predict(smile__svm_model_8F, tst_smile_girls)
summary(smile__svm_model_8F.2_pred)
## spontaneous deliberate  
##          38          27
smile__svm_model_8F.2_confM <- confusionMatrix(
  smile__svm_model_8F.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_8F.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          24          14
##   deliberate            9          18
##                                           
##                Accuracy : 0.6462          
##                  95% CI : (0.5177, 0.7608)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.01698         
##                                           
##                   Kappa : 0.2905          
##                                           
##  Mcnemar's Test P-Value : 0.40425         
##                                           
##             Sensitivity : 0.7273          
##             Specificity : 0.5625          
##          Pos Pred Value : 0.6316          
##          Neg Pred Value : 0.6667          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3692          
##    Detection Prevalence : 0.5846          
##       Balanced Accuracy : 0.6449          
##                                           
##        'Positive' Class : spontaneous     
## 
# 8G
set.seed(1973)
smile__svm_model_8G <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + onset_mean + eye_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_8G$results
##   C  Accuracy      Kappa AccuracySD    KappaSD
## 1 1 0.5408422 0.08175117 0.04353818 0.08936622
smile__svm_model_8G_pred <- predict(smile__svm_model_8G, tst_smile)
summary(smile__svm_model_8G_pred)
## spontaneous deliberate  
##          73          69
smile__svm_model_8G_confM <- confusionMatrix(
  smile__svm_model_8G_pred,
  tst_smile$smile_type
)
smile__svm_model_8G_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          42          31
##   deliberate           28          41
##                                           
##                Accuracy : 0.5845          
##                  95% CI : (0.4989, 0.6665)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.03874         
##                                           
##                   Kappa : 0.1693          
##                                           
##  Mcnemar's Test P-Value : 0.79457         
##                                           
##             Sensitivity : 0.6000          
##             Specificity : 0.5694          
##          Pos Pred Value : 0.5753          
##          Neg Pred Value : 0.5942          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2958          
##    Detection Prevalence : 0.5141          
##       Balanced Accuracy : 0.5847          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_8G.1_pred <- predict(smile__svm_model_8G, tst_smile_boys)
summary(smile__svm_model_8G.1_pred)
## spontaneous deliberate  
##          33          44
smile__svm_model_8G.1_confM <- confusionMatrix(
  smile__svm_model_8G.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_8G.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          17          16
##   deliberate           20          24
##                                           
##                Accuracy : 0.5325          
##                  95% CI : (0.4152, 0.6471)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.4552          
##                                           
##                   Kappa : 0.0597          
##                                           
##  Mcnemar's Test P-Value : 0.6171          
##                                           
##             Sensitivity : 0.4595          
##             Specificity : 0.6000          
##          Pos Pred Value : 0.5152          
##          Neg Pred Value : 0.5455          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2208          
##    Detection Prevalence : 0.4286          
##       Balanced Accuracy : 0.5297          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_8G.2_pred <- predict(smile__svm_model_8G, tst_smile_girls)
summary(smile__svm_model_8G.2_pred)
## spontaneous deliberate  
##          40          25
smile__svm_model_8G.2_confM <- confusionMatrix(
  smile__svm_model_8G.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_8G.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          25          15
##   deliberate            8          17
##                                           
##                Accuracy : 0.6462          
##                  95% CI : (0.5177, 0.7608)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.01698         
##                                           
##                   Kappa : 0.2898          
##                                           
##  Mcnemar's Test P-Value : 0.21090         
##                                           
##             Sensitivity : 0.7576          
##             Specificity : 0.5312          
##          Pos Pred Value : 0.6250          
##          Neg Pred Value : 0.6800          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3846          
##    Detection Prevalence : 0.6154          
##       Balanced Accuracy : 0.6444          
##                                           
##        'Positive' Class : spontaneous     
## 
# 8H
set.seed(1973)
smile__svm_model_8H <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + apex_mean + eye_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_8H$results
##   C  Accuracy    Kappa AccuracySD   KappaSD
## 1 1 0.5591188 0.118238 0.06334477 0.1273335
smile__svm_model_8H_pred <- predict(smile__svm_model_8H, tst_smile)
summary(smile__svm_model_8H_pred)
## spontaneous deliberate  
##          66          76
smile__svm_model_8H_confM <- confusionMatrix(
  smile__svm_model_8H_pred,
  tst_smile$smile_type
)
smile__svm_model_8H_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          36          30
##   deliberate           34          42
##                                           
##                Accuracy : 0.5493          
##                  95% CI : (0.4636, 0.6328)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.1780          
##                                           
##                   Kappa : 0.0977          
##                                           
##  Mcnemar's Test P-Value : 0.7077          
##                                           
##             Sensitivity : 0.5143          
##             Specificity : 0.5833          
##          Pos Pred Value : 0.5455          
##          Neg Pred Value : 0.5526          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2535          
##    Detection Prevalence : 0.4648          
##       Balanced Accuracy : 0.5488          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_8H.1_pred <- predict(smile__svm_model_8H, tst_smile_boys)
summary(smile__svm_model_8H.1_pred)
## spontaneous deliberate  
##          27          50
smile__svm_model_8H.1_confM <- confusionMatrix(
  smile__svm_model_8H.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_8H.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          16          11
##   deliberate           21          29
##                                           
##                Accuracy : 0.5844          
##                  95% CI : (0.4664, 0.6957)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.1523          
##                                           
##                   Kappa : 0.159           
##                                           
##  Mcnemar's Test P-Value : 0.1116          
##                                           
##             Sensitivity : 0.4324          
##             Specificity : 0.7250          
##          Pos Pred Value : 0.5926          
##          Neg Pred Value : 0.5800          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2078          
##    Detection Prevalence : 0.3506          
##       Balanced Accuracy : 0.5787          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_8H.2_pred <- predict(smile__svm_model_8H, tst_smile_girls)
summary(smile__svm_model_8H.2_pred)
## spontaneous deliberate  
##          39          26
smile__svm_model_8H.2_confM <- confusionMatrix(
  smile__svm_model_8H.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_8H.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          20          19
##   deliberate           13          13
##                                          
##                Accuracy : 0.5077         
##                  95% CI : (0.3807, 0.634)
##     No Information Rate : 0.5077         
##     P-Value [Acc > NIR] : 0.5495         
##                                          
##                   Kappa : 0.0123         
##                                          
##  Mcnemar's Test P-Value : 0.3768         
##                                          
##             Sensitivity : 0.6061         
##             Specificity : 0.4062         
##          Pos Pred Value : 0.5128         
##          Neg Pred Value : 0.5000         
##              Prevalence : 0.5077         
##          Detection Rate : 0.3077         
##    Detection Prevalence : 0.6000         
##       Balanced Accuracy : 0.5062         
##                                          
##        'Positive' Class : spontaneous    
## 
# 8I
set.seed(1973)
smile__svm_model_8I <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + offset_mean + eye_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_8I$results
##   C  Accuracy    Kappa AccuracySD   KappaSD
## 1 1 0.5761308 0.152213 0.07350272 0.1491875
smile__svm_model_8I_pred <- predict(smile__svm_model_8I, tst_smile)
summary(smile__svm_model_8I_pred)
## spontaneous deliberate  
##          67          75
smile__svm_model_8I_confM <- confusionMatrix(
  smile__svm_model_8I_pred,
  tst_smile$smile_type
)
smile__svm_model_8I_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          39          28
##   deliberate           31          44
##                                           
##                Accuracy : 0.5845          
##                  95% CI : (0.4989, 0.6665)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 0.03874         
##                                           
##                   Kappa : 0.1684          
##                                           
##  Mcnemar's Test P-Value : 0.79457         
##                                           
##             Sensitivity : 0.5571          
##             Specificity : 0.6111          
##          Pos Pred Value : 0.5821          
##          Neg Pred Value : 0.5867          
##              Prevalence : 0.4930          
##          Detection Rate : 0.2746          
##    Detection Prevalence : 0.4718          
##       Balanced Accuracy : 0.5841          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_8I.1_pred <- predict(smile__svm_model_8I, tst_smile_boys)
summary(smile__svm_model_8I.1_pred)
## spontaneous deliberate  
##          29          48
smile__svm_model_8I.1_confM <- confusionMatrix(
  smile__svm_model_8I.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_8I.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          15          14
##   deliberate           22          26
##                                           
##                Accuracy : 0.5325          
##                  95% CI : (0.4152, 0.6471)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.4552          
##                                           
##                   Kappa : 0.0559          
##                                           
##  Mcnemar's Test P-Value : 0.2433          
##                                           
##             Sensitivity : 0.4054          
##             Specificity : 0.6500          
##          Pos Pred Value : 0.5172          
##          Neg Pred Value : 0.5417          
##              Prevalence : 0.4805          
##          Detection Rate : 0.1948          
##    Detection Prevalence : 0.3766          
##       Balanced Accuracy : 0.5277          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_8I.2_pred <- predict(smile__svm_model_8I, tst_smile_girls)
summary(smile__svm_model_8I.2_pred)
## spontaneous deliberate  
##          38          27
smile__svm_model_8I.2_confM <- confusionMatrix(
  smile__svm_model_8I.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_8I.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          24          14
##   deliberate            9          18
##                                           
##                Accuracy : 0.6462          
##                  95% CI : (0.5177, 0.7608)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.01698         
##                                           
##                   Kappa : 0.2905          
##                                           
##  Mcnemar's Test P-Value : 0.40425         
##                                           
##             Sensitivity : 0.7273          
##             Specificity : 0.5625          
##          Pos Pred Value : 0.6316          
##          Neg Pred Value : 0.6667          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3692          
##    Detection Prevalence : 0.5846          
##       Balanced Accuracy : 0.6449          
##                                           
##        'Positive' Class : spontaneous     
## 
# 8J
set.seed(1973)
smile__svm_model_8J <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean + onset_mean + apex_mean +
  offset_mean + lip_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_8J$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.6926081 0.3854562  0.0926346 0.1859359
smile__svm_model_8J_pred <- predict(smile__svm_model_8J, tst_smile)
summary(smile__svm_model_8J_pred)
## spontaneous deliberate  
##          69          73
smile__svm_model_8J_confM <- confusionMatrix(
  smile__svm_model_8J_pred,
  tst_smile$smile_type
)
smile__svm_model_8J_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          47          22
##   deliberate           23          50
##                                           
##                Accuracy : 0.6831          
##                  95% CI : (0.5998, 0.7586)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 1.596e-05       
##                                           
##                   Kappa : 0.3659          
##                                           
##  Mcnemar's Test P-Value : 1               
##                                           
##             Sensitivity : 0.6714          
##             Specificity : 0.6944          
##          Pos Pred Value : 0.6812          
##          Neg Pred Value : 0.6849          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3310          
##    Detection Prevalence : 0.4859          
##       Balanced Accuracy : 0.6829          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_8J.1_pred <- predict(smile__svm_model_8J, tst_smile_boys)
summary(smile__svm_model_8J.1_pred)
## spontaneous deliberate  
##          30          47
smile__svm_model_8J.1_confM <- confusionMatrix(
  smile__svm_model_8J.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_8J.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          22           8
##   deliberate           15          32
##                                           
##                Accuracy : 0.7013          
##                  95% CI : (0.5862, 0.8003)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 0.0008966       
##                                           
##                   Kappa : 0.3974          
##                                           
##  Mcnemar's Test P-Value : 0.2109029       
##                                           
##             Sensitivity : 0.5946          
##             Specificity : 0.8000          
##          Pos Pred Value : 0.7333          
##          Neg Pred Value : 0.6809          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2857          
##    Detection Prevalence : 0.3896          
##       Balanced Accuracy : 0.6973          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_8J.2_pred <- predict(smile__svm_model_8J, tst_smile_girls)
summary(smile__svm_model_8J.2_pred)
## spontaneous deliberate  
##          39          26
smile__svm_model_8J.2_confM <- confusionMatrix(
  smile__svm_model_8J.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_8J.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          25          14
##   deliberate            8          18
##                                           
##                Accuracy : 0.6615          
##                  95% CI : (0.5335, 0.7743)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.008794        
##                                           
##                   Kappa : 0.321           
##                                           
##  Mcnemar's Test P-Value : 0.286422        
##                                           
##             Sensitivity : 0.7576          
##             Specificity : 0.5625          
##          Pos Pred Value : 0.6410          
##          Neg Pred Value : 0.6923          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3846          
##    Detection Prevalence : 0.6000          
##       Balanced Accuracy : 0.6600          
##                                           
##        'Positive' Class : spontaneous     
## 
# 8K
set.seed(1973)
smile__svm_model_8K <- train(smile_type ~ AU01_r_mean + AU09_r_mean +
  AU10_r_mean + AU25_r_mean + AU45_r_mean +
  onset_mean + apex_mean + offset_mean + lip_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_8K$results
##   C  Accuracy     Kappa AccuracySD  KappaSD
## 1 1 0.7196301 0.4390769  0.1031942 0.205939
smile__svm_model_8K_pred <- predict(smile__svm_model_8K, tst_smile)
summary(smile__svm_model_8K_pred)
## spontaneous deliberate  
##          63          79
smile__svm_model_8K_confM <- confusionMatrix(
  smile__svm_model_8K_pred,
  tst_smile$smile_type
)
smile__svm_model_8K_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          48          15
##   deliberate           22          57
##                                           
##                Accuracy : 0.7394          
##                  95% CI : (0.6592, 0.8094)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 1.288e-08       
##                                           
##                   Kappa : 0.478           
##                                           
##  Mcnemar's Test P-Value : 0.3239          
##                                           
##             Sensitivity : 0.6857          
##             Specificity : 0.7917          
##          Pos Pred Value : 0.7619          
##          Neg Pred Value : 0.7215          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3380          
##    Detection Prevalence : 0.4437          
##       Balanced Accuracy : 0.7387          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_8K.1_pred <- predict(smile__svm_model_8K, tst_smile_boys)
summary(smile__svm_model_8K.1_pred)
## spontaneous deliberate  
##          26          51
smile__svm_model_8K.1_confM <- confusionMatrix(
  smile__svm_model_8K.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_8K.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          22           4
##   deliberate           15          36
##                                           
##                Accuracy : 0.7532          
##                  95% CI : (0.6418, 0.8444)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 2.185e-05       
##                                           
##                   Kappa : 0.5002          
##                                           
##  Mcnemar's Test P-Value : 0.02178         
##                                           
##             Sensitivity : 0.5946          
##             Specificity : 0.9000          
##          Pos Pred Value : 0.8462          
##          Neg Pred Value : 0.7059          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2857          
##    Detection Prevalence : 0.3377          
##       Balanced Accuracy : 0.7473          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_8K.2_pred <- predict(smile__svm_model_8K, tst_smile_girls)
summary(smile__svm_model_8K.2_pred)
## spontaneous deliberate  
##          37          28
smile__svm_model_8K.2_confM <- confusionMatrix(
  smile__svm_model_8K.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_8K.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          26          11
##   deliberate            7          21
##                                           
##                Accuracy : 0.7231          
##                  95% CI : (0.5981, 0.8269)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.0003328       
##                                           
##                   Kappa : 0.445           
##                                           
##  Mcnemar's Test P-Value : 0.4795001       
##                                           
##             Sensitivity : 0.7879          
##             Specificity : 0.6562          
##          Pos Pred Value : 0.7027          
##          Neg Pred Value : 0.7500          
##              Prevalence : 0.5077          
##          Detection Rate : 0.4000          
##    Detection Prevalence : 0.5692          
##       Balanced Accuracy : 0.7221          
##                                           
##        'Positive' Class : spontaneous     
## 
# 8L
set.seed(1973)
smile__svm_model_8L <- train(smile_type ~ AU01_r_mean + AU09_r_mean +
  AU10_r_mean + AU25_r_mean + AU45_r_mean +
  onset_mean + apex_mean + offset_mean + eye_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_8L$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.6897616 0.3788924 0.08931016 0.1785103
smile__svm_model_8L_pred <- predict(smile__svm_model_8L, tst_smile)
summary(smile__svm_model_8L_pred)
## spontaneous deliberate  
##          60          82
smile__svm_model_8L_confM <- confusionMatrix(
  smile__svm_model_8L_pred,
  tst_smile$smile_type
)
smile__svm_model_8L_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          44          16
##   deliberate           26          56
##                                           
##                Accuracy : 0.7042          
##                  95% CI : (0.6219, 0.7778)
##     No Information Rate : 0.507           
##     P-Value [Acc > NIR] : 1.414e-06       
##                                           
##                   Kappa : 0.4072          
##                                           
##  Mcnemar's Test P-Value : 0.1649          
##                                           
##             Sensitivity : 0.6286          
##             Specificity : 0.7778          
##          Pos Pred Value : 0.7333          
##          Neg Pred Value : 0.6829          
##              Prevalence : 0.4930          
##          Detection Rate : 0.3099          
##    Detection Prevalence : 0.4225          
##       Balanced Accuracy : 0.7032          
##                                           
##        'Positive' Class : spontaneous     
## 
# predicting boys, girls
set.seed(1973)
smile__svm_model_8L.1_pred <- predict(smile__svm_model_8L, tst_smile_boys)
summary(smile__svm_model_8L.1_pred)
## spontaneous deliberate  
##          25          52
smile__svm_model_8L.1_confM <- confusionMatrix(
  smile__svm_model_8L.1_pred,
  tst_smile_boys$smile_type
)
smile__svm_model_8L.1_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          21           4
##   deliberate           16          36
##                                           
##                Accuracy : 0.7403          
##                  95% CI : (0.6277, 0.8336)
##     No Information Rate : 0.5195          
##     P-Value [Acc > NIR] : 6.073e-05       
##                                           
##                   Kappa : 0.4733          
##                                           
##  Mcnemar's Test P-Value : 0.01391         
##                                           
##             Sensitivity : 0.5676          
##             Specificity : 0.9000          
##          Pos Pred Value : 0.8400          
##          Neg Pred Value : 0.6923          
##              Prevalence : 0.4805          
##          Detection Rate : 0.2727          
##    Detection Prevalence : 0.3247          
##       Balanced Accuracy : 0.7338          
##                                           
##        'Positive' Class : spontaneous     
## 
set.seed(1973)
smile__svm_model_8L.2_pred <- predict(smile__svm_model_8L, tst_smile_girls)
summary(smile__svm_model_8L.2_pred)
## spontaneous deliberate  
##          35          30
smile__svm_model_8L.2_confM <- confusionMatrix(
  smile__svm_model_8L.2_pred,
  tst_smile_girls$smile_type
)
smile__svm_model_8L.2_confM
## Confusion Matrix and Statistics
## 
##              Reference
## Prediction    spontaneous deliberate 
##   spontaneous          23          12
##   deliberate           10          20
##                                           
##                Accuracy : 0.6615          
##                  95% CI : (0.5335, 0.7743)
##     No Information Rate : 0.5077          
##     P-Value [Acc > NIR] : 0.008794        
##                                           
##                   Kappa : 0.3223          
##                                           
##  Mcnemar's Test P-Value : 0.831170        
##                                           
##             Sensitivity : 0.6970          
##             Specificity : 0.6250          
##          Pos Pred Value : 0.6571          
##          Neg Pred Value : 0.6667          
##              Prevalence : 0.5077          
##          Detection Rate : 0.3538          
##    Detection Prevalence : 0.5385          
##       Balanced Accuracy : 0.6610          
##                                           
##        'Positive' Class : spontaneous     
## 
# test two models without temporal features
# they do not improve the accuracy scores
set.seed(1973)
smile__svm_model_9 <- train(smile_type ~ AU01_r_mean + AU09_r_mean +
  AU10_r_mean + AU25_r_mean + AU45_r_mean +
  lip_mean + eye_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_9$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.6362021 0.2726033  0.0691034 0.1362343
set.seed(1973)
smile__svm_model_10 <- train(smile_type ~ AU06_r_mean + AU12_r_mean +
  AU45_r_mean +
  lip_mean + eye_mean,
method = "svmLinear", data = trn_smile,
trControl = trainControl(method = "cv", number = 10)
)

smile__svm_model_10$results
##   C  Accuracy     Kappa AccuracySD   KappaSD
## 1 1 0.5677585 0.1365759 0.05687368 0.1156556

Part 4: packages and other information

Installing other liberaries and packages

In the exploration phase of the thesis the OpenFacer package was tested. This package published on GitHub, needed installation via the devtools package. The installation code is shown below.

# install_github("davidecannatanuig/openFaceR")
library(openfacer)
# citation("openfacer")
# library(devtools)
# citation("devtools")

Using Openfacer

Openfacer is a tool developed for social sientists. This tool is used to set up feature creation of this study and as it resources were to limited, the results on the descriptive statistics were compared. They show the same outcome, and the choice was made to move on with database which was build by myself, because of more flexibility in the analysis.

# loading packages
library(openfacer)
library(readr)
library(tidyverse)

# read the CSV files at once into RStudio
UvA_face <- read_face_csvs("Data_Openface/CSV/")

# create features using a pipeline
UvA_final_face <- UvA_face %>%
  select_faces(
    starts_with("gaze_"), starts_with("pose_"), starts_with("AU06"),
    starts_with("AU12"), x_36, x_37, x_38, x_39, x_42, x_43, x_44, x_45,
    x_48, x_54, y_36, y_37, y_38, y_39, y_42, y_43, y_44, y_45, y_48,
    y_54
  ) %>%
  mutate_faces(AU06_12_c = ifelse(AU06_c == 1 & AU12_c == 1, 1, 0)) %>%
  mutate_faces(lip = sqrt((x_48 - x_54)^2 + (y_48 - y_54)^2)) %>%
  mutate_faces(eye_x_m_l = (x_36 + x_39) / 2) %>%
  mutate_faces(eye_y_m_l = (y_36 + y_39) / 2) %>%
  mutate_faces(eye_x_m_r = (x_42 + x_45) / 2) %>%
  mutate_faces(eye_y_m_r = (y_42 + y_45) / 2) %>%
  mutate_faces(eye_x_u_l = (x_37 + x_38) / 2) %>%
  mutate_faces(eye_y_u_l = (y_37 + y_38) / 2) %>%
  mutate_faces(eye_x_u_r = (x_43 + x_44) / 2) %>%
  mutate_faces(eye_y_u_r = (y_43 + y_44) / 2) %>%
  mutate_faces(eye_l = sqrt((eye_x_m_l - eye_x_u_l)^2 +
    (eye_y_m_l - eye_y_u_l)^2)) %>%
  mutate_faces(eye_r = sqrt((eye_x_m_r - eye_x_u_r)^2 +
    (eye_y_m_r - eye_y_u_r)^2)) %>%
  mutate_faces(eye = (eye_l + eye_r) / 2) %>%
  select_faces(
    starts_with("gaze_"), starts_with("pose_"), starts_with("AU06"),
    starts_with("AU12"), lip, eye_l, eye_r, eye
  ) %>%
  tidy_face()

# save the data frame
write_csv(UvA_final_face, "UvA_final_face")

# create a check file to the own created summary file.
# compare two files have the same content using all()
UvA_face_check <- read.csv("UvA_final_face")
# all()

Creation of a face figure as illustration

To support the thesis a figure is created displaying all the 2D landmark features. This is done based on subject number 20, as this subject is the only in database which data can be used in the report with permission of the data holder. The picture can be found in the thesis file.

library(ggplot2)
library(dplyr)
library(reshape2)
# citation("reshape2")

figure_1 <- read.csv("masterfile_connected")

figure_2 <- figure_1 %>%
  select(starts_with("x_"))

figure_2 <- figure_2[50, ]

fig_3 <- dcast(melt(as.matrix(figure_2)),
  Var2 ~ paste0("x", Var1),
  value.var = "value"
)

figure_4 <- figure_1 %>%
  select(starts_with("y_"))

figure_4 <- figure_4[50, ]

fig_5 <- dcast(melt(as.matrix(figure_4)),
  Var2 ~ paste0("y", Var1),
  value.var = "value"
)

fig_6 <- cbind(fig_5, fig_3)
fig_6 <- fig_6[1:68, ]
fig_6$Var2 <- gsub("y_", "", fig_6$Var2)

par(mfrow = c(1, 1))
dev.new(width = 5, height = 8)
plot(fig_6$x50, fig_6$y50,
  xlim = c(950, 400), ylim = c(850, 300),
  col = "blue",
  xlab = "landmark x points", ylab = "landmark y points"
)
text(fig_6$x50, fig_6$y50, labels = fig_6$Var2, cex = .6, pos = 4)